atom
This commit is contained in:
84
src/main/java/dev/tggamesyt/szar/AtomEntity.java
Normal file
84
src/main/java/dev/tggamesyt/szar/AtomEntity.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package dev.tggamesyt.szar;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.MovementType;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class AtomEntity extends Entity {
|
||||
private static final int NUKE_RADIUS = 100;
|
||||
public AtomEntity(EntityType<?> type, World world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDataTracker() {}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
if (!this.hasNoGravity()) {
|
||||
this.setVelocity(this.getVelocity().add(0, -0.08, 0));
|
||||
}
|
||||
|
||||
this.move(MovementType.SELF, this.getVelocity());
|
||||
|
||||
if (!getWorld().isClient && this.isOnGround()) {
|
||||
explode();
|
||||
this.discard();
|
||||
}
|
||||
}
|
||||
|
||||
private void explode() {
|
||||
ServerWorld world = (ServerWorld) this.getWorld();
|
||||
|
||||
// Visual / sound explosion only
|
||||
world.createExplosion(
|
||||
this,
|
||||
getX(),
|
||||
getY(),
|
||||
getZ(),
|
||||
50.0F, // just visuals
|
||||
World.ExplosionSourceType.TNT
|
||||
);
|
||||
|
||||
clearSphere(world, this.getBlockPos(), NUKE_RADIUS);
|
||||
}
|
||||
private void clearSphere(ServerWorld world, BlockPos center, int radius) {
|
||||
int rSquared = radius * radius;
|
||||
|
||||
BlockPos.Mutable mutable = new BlockPos.Mutable();
|
||||
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
for (int y = -radius; y <= radius; y++) {
|
||||
for (int z = -radius; z <= radius; z++) {
|
||||
|
||||
if (x * x + y * y + z * z > rSquared) continue;
|
||||
|
||||
mutable.set(
|
||||
center.getX() + x,
|
||||
center.getY() + y,
|
||||
center.getZ() + z
|
||||
);
|
||||
|
||||
// Skip void / out of world
|
||||
if (!world.isInBuildLimit(mutable)) continue;
|
||||
|
||||
world.setBlockState(mutable, net.minecraft.block.Blocks.AIR.getDefaultState(), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void readCustomDataFromNbt(NbtCompound nbt) {}
|
||||
|
||||
@Override
|
||||
protected void writeCustomDataToNbt(NbtCompound nbt) {}
|
||||
}
|
||||
66
src/main/java/dev/tggamesyt/szar/AtomSummonerItem.java
Normal file
66
src/main/java/dev/tggamesyt/szar/AtomSummonerItem.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package dev.tggamesyt.szar;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.world.RaycastContext;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class AtomSummonerItem extends Item {
|
||||
|
||||
private static final int COOLDOWN_TICKS = 20 * 60; // 10 minutes
|
||||
private static final double RAY_DISTANCE = 500.0D;
|
||||
|
||||
public AtomSummonerItem(Settings settings) {
|
||||
super(settings.maxDamage(2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
|
||||
if (world.isClient()) {
|
||||
return TypedActionResult.success(player.getStackInHand(hand));
|
||||
}
|
||||
|
||||
ServerWorld serverWorld = (ServerWorld) world;
|
||||
ItemStack stack = player.getStackInHand(hand);
|
||||
|
||||
// Raycast from eyes
|
||||
Vec3d start = player.getCameraPosVec(1.0F);
|
||||
Vec3d direction = player.getRotationVec(1.0F);
|
||||
Vec3d end = start.add(direction.multiply(RAY_DISTANCE));
|
||||
|
||||
BlockHitResult hit = serverWorld.raycast(new RaycastContext(
|
||||
start,
|
||||
end,
|
||||
RaycastContext.ShapeType.OUTLINE,
|
||||
RaycastContext.FluidHandling.NONE,
|
||||
player
|
||||
));
|
||||
|
||||
// If player is looking into nothing, abort
|
||||
if (hit.getType() == HitResult.Type.MISS) {
|
||||
return TypedActionResult.fail(stack);
|
||||
}
|
||||
|
||||
BlockPos hitPos = hit.getBlockPos();
|
||||
Vec3d spawnPos = Vec3d.ofCenter(hitPos).add(0, 100, 0);
|
||||
|
||||
AtomEntity atom = new AtomEntity(Szar.AtomEntityType, serverWorld);
|
||||
atom.setPosition(spawnPos.x, spawnPos.y, spawnPos.z);
|
||||
|
||||
serverWorld.spawnEntity(atom);
|
||||
|
||||
// Cooldown + durability
|
||||
player.getItemCooldownManager().set(this, COOLDOWN_TICKS);
|
||||
stack.damage(1, player, p -> p.sendToolBreakStatus(hand));
|
||||
|
||||
return TypedActionResult.success(stack);
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class Szar implements ModInitializer {
|
||||
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
|
||||
public static MinecraftServer SERVER;
|
||||
public static final Identifier PLANE_ANIM_PACKET =
|
||||
new Identifier("szar", "plane_anim");
|
||||
new Identifier(MOD_ID, "plane_anim");
|
||||
public static final Identifier OPEN_URL = new Identifier(MOD_ID, "epsteinfiles");
|
||||
|
||||
public static final Block SZAR_BLOCK =
|
||||
@@ -99,7 +99,7 @@ public class Szar implements ModInitializer {
|
||||
public static final RegistryKey<DamageType> BULLET_DAMAGE =
|
||||
RegistryKey.of(
|
||||
RegistryKeys.DAMAGE_TYPE,
|
||||
new Identifier("szar", "bullet")
|
||||
new Identifier(MOD_ID, "bullet")
|
||||
);
|
||||
public static VillagerProfession DROG_DEALER = Registry.register(
|
||||
Registries.VILLAGER_PROFESSION,
|
||||
@@ -233,6 +233,7 @@ public class Szar implements ModInitializer {
|
||||
entries.add(Szar.NYAN_SPAWNEGG);
|
||||
entries.add(Szar.EPSTEIN_FILES);
|
||||
entries.add(Szar.EPSTEIN_SPAWNEGG);
|
||||
entries.add(Szar.ATOM_DETONATOR);
|
||||
})
|
||||
.build()
|
||||
);
|
||||
@@ -476,7 +477,7 @@ public class Szar implements ModInitializer {
|
||||
GenerationStep.Feature.VEGETAL_DECORATION,
|
||||
RegistryKey.of(
|
||||
RegistryKeys.PLACED_FEATURE,
|
||||
new Identifier("szar", "cannabis_patch")
|
||||
new Identifier(MOD_ID, "cannabis_patch")
|
||||
)
|
||||
);
|
||||
AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
|
||||
@@ -522,7 +523,7 @@ public class Szar implements ModInitializer {
|
||||
public static final Feature<CannabisPatchFeatureConfig> CANNABIS_PATCH =
|
||||
Registry.register(
|
||||
Registries.FEATURE,
|
||||
new Identifier("szar", "cannabis_patch"),
|
||||
new Identifier(MOD_ID, "cannabis_patch"),
|
||||
new CannabisPatchFeature(CannabisPatchFeatureConfig.CODEC)
|
||||
);
|
||||
public static final Map<UUID, Integer> PLAYER_JOINT_LEVEL = new HashMap<>();
|
||||
@@ -532,25 +533,36 @@ public class Szar implements ModInitializer {
|
||||
new Identifier(MOD_ID, "drog"),
|
||||
new DrogEffect()
|
||||
);
|
||||
public static final StatusEffect ARRESTED = Registry.register(Registries.STATUS_EFFECT, new Identifier("szar", "arrested"), new ArrestedEffect());
|
||||
public static final StatusEffect ARRESTED = Registry.register(Registries.STATUS_EFFECT, new Identifier(MOD_ID, "arrested"), new ArrestedEffect());
|
||||
public static final Item AK_AMMO = Registry.register(
|
||||
Registries.ITEM,
|
||||
new Identifier("szar", "bullet"),
|
||||
new Identifier(MOD_ID, "bullet"),
|
||||
new Item(new Item.Settings())
|
||||
);
|
||||
public static final EntityType<BulletEntity> BULLET =
|
||||
Registry.register(
|
||||
Registries.ENTITY_TYPE,
|
||||
new Identifier("szar", "bullet"),
|
||||
new Identifier(MOD_ID, "bullet"),
|
||||
FabricEntityTypeBuilder.<BulletEntity>create(SpawnGroup.MISC, BulletEntity::new)
|
||||
.dimensions(EntityDimensions.fixed(0.25F, 0.25F))
|
||||
.trackRangeBlocks(64)
|
||||
.trackedUpdateRate(20)
|
||||
.build()
|
||||
);
|
||||
public static final EntityType<AtomEntity> AtomEntityType =
|
||||
Registry.register(
|
||||
Registries.ENTITY_TYPE,
|
||||
new Identifier(MOD_ID, "atom"),
|
||||
FabricEntityTypeBuilder.create()
|
||||
.entityFactory(AtomEntity::new)
|
||||
.dimensions(EntityDimensions.fixed(2.0F, 6.0F))
|
||||
.trackRangeBlocks(256)
|
||||
.trackedUpdateRate(1)
|
||||
.build()
|
||||
);
|
||||
public static final Item AK47 = Registry.register(
|
||||
Registries.ITEM,
|
||||
new Identifier("szar", "ak47"),
|
||||
new Identifier(MOD_ID, "ak47"),
|
||||
new AK47Item(new Item.Settings().maxCount(1))
|
||||
);
|
||||
|
||||
@@ -714,7 +726,7 @@ public class Szar implements ModInitializer {
|
||||
new FaszItem(FASZ_BLOCK, new Item.Settings())
|
||||
);
|
||||
public static final SoundEvent NYAN_MUSIC =
|
||||
SoundEvent.of(new Identifier("szar", "nyan_music"));
|
||||
SoundEvent.of(new Identifier(MOD_ID, "nyan_music"));
|
||||
public static final Item POPTART = Registry.register(
|
||||
Registries.ITEM,
|
||||
new Identifier(MOD_ID, "pop_tart"),
|
||||
@@ -724,6 +736,11 @@ public class Szar implements ModInitializer {
|
||||
hunger((Math.random() < 0.5) ? 6 : 7) // SIX OR SEVEN
|
||||
.build()), 217)
|
||||
);
|
||||
public static final Item ATOM_DETONATOR = Registry.register(
|
||||
Registries.ITEM,
|
||||
new Identifier(MOD_ID, "detonator"),
|
||||
new AtomSummonerItem(new Item.Settings())
|
||||
);
|
||||
public static final Item NWORD_PASS = Registry.register(
|
||||
Registries.ITEM,
|
||||
new Identifier(MOD_ID, "nwordpass"),
|
||||
|
||||
@@ -53,5 +53,8 @@
|
||||
"szar.nyan_cat_start": "Nyan Cat Starts Performing",
|
||||
"item.szar.epstein_files": "Epstein Files",
|
||||
"entity.szar.epstein": "Epstein",
|
||||
"item.szar.epstein_spawn_egg": "Epstein Spawn Egg"
|
||||
"item.szar.epstein_spawn_egg": "Epstein Spawn Egg",
|
||||
|
||||
"item.szar.detonator": "Detonator",
|
||||
"entity.szar.atom": "Atom"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "szar:item/detonator"
|
||||
}
|
||||
}
|
||||
BIN
src/main/resources/assets/szar/textures/entity/nuke.png
Normal file
BIN
src/main/resources/assets/szar/textures/entity/nuke.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
src/main/resources/assets/szar/textures/item/detonator.png
Normal file
BIN
src/main/resources/assets/szar/textures/item/detonator.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 722 B |
Reference in New Issue
Block a user