Skip to content

Commit

Permalink
Fixed a lot of various non-worldgen related issues
Browse files Browse the repository at this point in the history
Attempted to fix ruins causing world to freeze, by re-exporting all structures - without luck.
  • Loading branch information
GirafiStudios committed Oct 14, 2020
1 parent 6849803 commit d7c4497
Show file tree
Hide file tree
Showing 43 changed files with 90 additions and 78 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/teammetallurgy/atum/Atum.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.teammetallurgy.atum;

import com.mojang.serialization.Codec;
import com.teammetallurgy.atum.api.AtumAPI;
import com.teammetallurgy.atum.blocks.stone.khnumite.KhnumiteFaceBlock;
import com.teammetallurgy.atum.client.ClientHandler;
import com.teammetallurgy.atum.commands.AtumWeather;
Expand Down Expand Up @@ -44,6 +45,7 @@ public Atum() {
MinecraftForge.EVENT_BUS.addListener(this::onServerStarting);
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, AtumConfig.spec);
IntegrationHandler.INSTANCE.addSupport();
AtumAPI.Tags.init();
}

private void setupCommon(FMLCommonSetupEvent event) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/teammetallurgy/atum/api/AtumAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,8 @@ public static IOptionalNamedTag<Item> tag(String modID, String name) {
public static IOptionalNamedTag<Block> blockTag(String modID, String name) {
return BlockTags.createOptional(new ResourceLocation(modID, name));
}

public static void init() {
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.teammetallurgy.atum.blocks.stone.limestone;

import com.teammetallurgy.atum.Atum;
import com.teammetallurgy.atum.blocks.machines.KilnBlock;
import com.teammetallurgy.atum.init.AtumBlocks;
import net.minecraft.block.Block;
Expand All @@ -14,9 +15,13 @@
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

import javax.annotation.Nonnull;

@Mod.EventBusSubscriber(modid = Atum.MOD_ID)
public class LimestoneBrickBlock extends Block {
public static final BooleanProperty UNBREAKABLE = BooleanProperty.create("unbreakable");

Expand Down Expand Up @@ -45,10 +50,13 @@ public void onBlockPlacedBy(@Nonnull World world, @Nonnull BlockPos pos, @Nonnul
}
}

/*@Override
public float getBlockHardness(BlockState state, IBlockReader world, BlockPos pos) { //TODO
return state.get(UNBREAKABLE) ? -1.0F : super.getBlockHardness(state, world, pos);
}*/
@SubscribeEvent
public static void onBlockBreak(BlockEvent.BreakEvent event) {
BlockState state = event.getState();
if (state.getBlock() instanceof LimestoneBrickBlock && state.get(LimestoneBrickBlock.UNBREAKABLE)) {
event.setCanceled(true);
}
}

@Override
public float getExplosionResistance(BlockState state, IBlockReader world, BlockPos pos, Explosion explosion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,24 @@
public class SarcophagusBlock extends ChestBaseBlock {

public SarcophagusBlock() {
super(() -> AtumTileEntities.SARCOPHAGUS, AbstractBlock.Properties.create(Material.ROCK, MaterialColor.SAND));
super(() -> AtumTileEntities.SARCOPHAGUS, AbstractBlock.Properties.create(Material.ROCK, MaterialColor.SAND).hardnessAndResistance(4.0F));
}

@Override
public TileEntity createNewTileEntity(@Nonnull IBlockReader reader) {
return new SarcophagusTileEntity();
}

/*@Override
public float getBlockHardness(@Nonnull BlockState state, IBlockReader world, @Nonnull BlockPos pos) { //TODO
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof SarcophagusTileEntity && !((SarcophagusTileEntity) tileEntity).isOpenable) {
return -1.0F;
} else {
return 4.0F;
@SubscribeEvent
public static void onBlockBreak(BlockEvent.BreakEvent event) {
BlockState state = event.getState();
if (state.getBlock() instanceof SarcophagusBlock) {
TileEntity tileEntity = event.getWorld().getTileEntity(event.getPos());
if (tileEntity instanceof SarcophagusTileEntity && !((SarcophagusTileEntity) tileEntity).isOpenable) {
event.setCanceled(true);
}
}
}*/
}

@Override
public float getExplosionResistance(BlockState state, IBlockReader world, BlockPos pos, Explosion explosion) {
Expand Down
20 changes: 15 additions & 5 deletions src/main/java/com/teammetallurgy/atum/blocks/trap/TrapBlock.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.teammetallurgy.atum.blocks.trap;

import com.teammetallurgy.atum.Atum;
import com.teammetallurgy.atum.blocks.trap.tileentity.TrapTileEntity;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
Expand All @@ -26,11 +27,15 @@
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.network.NetworkHooks;

import javax.annotation.Nonnull;
import java.util.Random;

@Mod.EventBusSubscriber(modid = Atum.MOD_ID)
public abstract class TrapBlock extends ContainerBlock {
public static final DirectionProperty FACING = DirectionalBlock.FACING;
private static final BooleanProperty DISABLED = BooleanProperty.create("disabled");
Expand All @@ -40,11 +45,16 @@ protected TrapBlock() {
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH).with(DISABLED, Boolean.FALSE));
}

/*@Override
public float getBlockHardness(@Nonnull BlockState state, IBlockReader world, @Nonnull BlockPos pos) { //TODO
TileEntity tileEntity = world.getTileEntity(pos);
return tileEntity instanceof TrapTileEntity && ((TrapTileEntity) tileEntity).isInsidePyramid ? -1.0F : super.getBlockHardness(state, world, pos);
}*/
@SubscribeEvent
public static void onBlockBreak(BlockEvent.BreakEvent event) {
BlockState state = event.getState();
if (state.getBlock() instanceof TrapBlock) {
TileEntity tileEntity = event.getWorld().getTileEntity(event.getPos());
if (tileEntity instanceof TrapTileEntity && ((TrapTileEntity) tileEntity).isInsidePyramid) {
event.setCanceled(true);
}
}
}

@Override
public float getExplosionResistance(BlockState state, IBlockReader world, BlockPos pos, Explosion explosion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,10 @@ public class DateBlock extends BushBlock implements IGrowable {
private static final VoxelShape BOUNDING_BOX = Block.makeCuboidShape(5.0D, 2.0D, 5.0D, 11.0D, 16.0D, 11.0D);

public DateBlock() {
super(Properties.create(Material.PLANTS).sound(SoundType.PLANT).notSolid().tickRandomly());
super(Properties.create(Material.PLANTS).sound(SoundType.PLANT).hardnessAndResistance(0.35F).notSolid().tickRandomly());
this.setDefaultState(this.stateContainer.getBaseState().with(AGE, 0));
}

/*@Override
public float getBlockHardness(BlockState state, IBlockReader world, BlockPos pos) { //TODO
if (state.get(AGE) != 3) {
return 0.25F;
}
return 0.35F;
}*/

@Override
@Nonnull
public VoxelShape getShape(BlockState state, @Nonnull IBlockReader reader, @Nonnull BlockPos pos, @Nonnull ISelectionContext context) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.teammetallurgy.atum.misc;
package com.teammetallurgy.atum.client;

import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3f;
Expand All @@ -23,8 +26,15 @@ public static void renderItem(TileEntity tileEntity, @Nonnull ItemStack stack, f
matrixStack.translate(0.5F, yOffset + 1.225F, 0.5F);

matrixStack.rotate(Vector3f.YP.rotationDegrees(rotation));
BlockState state = tileEntity.getBlockState();
if (state.hasProperty(BlockStateProperties.HORIZONTAL_FACING)) {
Direction facing = state.get(BlockStateProperties.HORIZONTAL_FACING);
if (facing == Direction.EAST || facing == Direction.WEST) {
matrixStack.rotate(Vector3f.YP.rotationDegrees(90.0F));
}
}
matrixStack.scale(0.25F, 0.25F, 0.25F);
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.FIXED, combinedLight, combinedOverlay, matrixStack, buffer);
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE, combinedLight, combinedOverlay, matrixStack, buffer);
matrixStack.pop();

if (drawStackSize) {
Expand All @@ -38,7 +48,7 @@ public static void drawString(TileEntity te, String str, double xOffset, double
TileEntityRendererDispatcher rendererDispatcher = TileEntityRendererDispatcher.instance;
Entity entity = rendererDispatcher.renderInfo.getRenderViewEntity();
BlockPos tePos = te.getPos();
double distance = new Vector3d(entity.getPosX(), entity.getPosY(), entity.getPosZ()).squareDistanceTo(tePos.getX(), tePos.getY(), tePos.getZ()); //TODO Test
double distance = new Vector3d(entity.getPosX(), entity.getPosY(), entity.getPosZ()).squareDistanceTo(tePos.getX(), tePos.getY(), tePos.getZ());

if (distance <= (double) (14 * 14)) {
float yaw = rendererDispatcher.renderInfo.getYaw();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import com.teammetallurgy.atum.Atum;
import com.teammetallurgy.atum.blocks.machines.QuernBlock;
import com.teammetallurgy.atum.blocks.machines.tileentity.QuernTileEntity;
import com.teammetallurgy.atum.client.RenderUtils;
import com.teammetallurgy.atum.init.AtumBlocks;
import com.teammetallurgy.atum.misc.RenderUtils;
import it.unimi.dsi.fastutil.ints.Int2IntFunction;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ protected void registerData() {
this.dataManager.register(ANGER, 0);
}

public static boolean canSpawn(EntityType<? extends DesertWolfEntity> animal, IServerWorld world, SpawnReason spawnReason, BlockPos pos, Random random) { //TODO test
public static boolean canSpawn(EntityType<? extends DesertWolfEntity> animal, IServerWorld world, SpawnReason spawnReason, BlockPos pos, Random random) {
return pos.getY() > 62 && ((ServerWorld) world.getChunkProvider().getWorld()).getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && world.canBlockSeeSky(pos) && AtumEntities.canAnimalSpawn(animal, world, spawnReason, pos, random);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected void registerData() {
@Nullable
public ILivingEntityData onInitialSpawn(@Nonnull IServerWorld world, @Nonnull DifficultyInstance difficulty, @Nonnull SpawnReason spawnReason, @Nullable ILivingEntityData livingdata, @Nullable CompoundNBT nbt) {
livingdata = super.onInitialSpawn(world, difficulty, spawnReason, livingdata, nbt);
if (rand.nextDouble() <= 0.002D) { //TODO Test golden scarab is working, and values is correct
if (rand.nextDouble() <= 0.002D) {
this.setVariant(1);
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(24.0D);
this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(3.0D);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ArrowExplosiveEntity(World world, LivingEntity shooter, float velocity) {

@Override
public void tick() {
if (this.timeInGround == 0 && velocity == 1.0F && !this.inGround && world.getGameTime() % 2L == 0L) { //TODO Test if timeinGround works, instead of ticksInAir
if (this.timeInGround == 20 && velocity == 1.0F && !this.inGround && world.getGameTime() % 2L == 0L) {
world.playSound(null, getPosition(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.PLAYERS, 1.0F, 1.0F);
}
super.tick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void tick() {
}
}
if (velocity == 1.0F && this.func_234616_v_() instanceof LivingEntity) {
if (this.ticksExisted == 12) { //TODO Test
if (this.ticksExisted == 12) {
this.remove();
if (!isSmallArrow) {
ArrowRainEntity arrow1 = new ArrowRainEntity(world, this.getPosX() + 0.5D, this.getPosY(), this.getPosZ());
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/teammetallurgy/atum/init/AtumRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.potion.Potions;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
Expand All @@ -22,7 +23,6 @@ public static void registerRecipes(RegistryEvent.Register<IRecipeSerializer<?>>
}

private static void addBrewingRecipes() {
//addBrewingRecipeWithSubPotions(AtumAPI.Tags.DUSTS_BLAZE, Potions.STRENGTH); //TODO
addBrewingRecipeWithSubPotions(new ItemStack(AtumItems.DUSTY_BONE), Potions.FIRE_RESISTANCE);
addBrewingRecipeWithSubPotions(new ItemStack(AtumItems.ECTOPLASM), Potions.INVISIBILITY);
addBrewingRecipeWithSubPotions(new ItemStack(AtumItems.GLISTERING_DATE), Potions.REGENERATION);
Expand All @@ -33,10 +33,10 @@ private static void addBrewingRecipes() {
addBrewingRecipeWithSubPotions(new ItemStack(AtumItems.OPHIDIAN_TONGUE_FLOWER), Potions.POISON);

//Anput's Fingers
/*Ingredient cropNetherWart = Ingredient.fromTag(Tags.Items.CROPS_NETHER_WART); //TODO
addRecipe(addPotionToItemStack(new ItemStack(Items.POTION), Potions.WATER), cropNetherWart, addPotionToItemStack(new ItemStack(Items.POTION), Potions.AWKWARD));
addRecipe(addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), Potions.WATER), cropNetherWart, addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), Potions.AWKWARD));
addRecipe(addPotionToItemStack(new ItemStack(Items.LINGERING_POTION), Potions.WATER), cropNetherWart, addPotionToItemStack(new ItemStack(Items.LINGERING_POTION), Potions.AWKWARD));*/
Ingredient anputsFingers = Ingredient.fromItems(AtumItems.ANPUTS_FINGERS_SPORES);
addRecipe(addPotionToItemStack(new ItemStack(Items.POTION), Potions.WATER), anputsFingers, addPotionToItemStack(new ItemStack(Items.POTION), Potions.AWKWARD));
addRecipe(addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), Potions.WATER), anputsFingers, addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), Potions.AWKWARD));
addRecipe(addPotionToItemStack(new ItemStack(Items.LINGERING_POTION), Potions.WATER), anputsFingers, addPotionToItemStack(new ItemStack(Items.LINGERING_POTION), Potions.AWKWARD));

//Fertile Soil modifier (Glowstone)
addRecipe(addPotionToItemStack(new ItemStack(Items.POTION), Potions.LEAPING), new ItemStack(AtumItems.FERTILE_SOIL_PILE), addPotionToItemStack(new ItemStack(Items.POTION), Potions.STRONG_LEAPING));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Class<? extends KilnRecipe> getRecipeClass() {
@Override
@Nonnull
public String getTitle() {
return new TranslationTextComponent(Atum.MOD_ID + "." + getUid().getPath()).toString(); //TODO Test
return new TranslationTextComponent(Atum.MOD_ID + "." + getUid().getPath()).getString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull QuernRecipe

@Override
public void draw(QuernRecipe recipe, @Nonnull MatrixStack matrixStack, double mouseX, double mouseY) {
Minecraft.getInstance().fontRenderer.func_243246_a(matrixStack, new TranslationTextComponent("gui.atum.rotations", recipe.getRotations()), 32, 0, Color.gray.getRGB());
Minecraft.getInstance().fontRenderer.func_243248_b(matrixStack, new TranslationTextComponent("gui.atum.rotations", recipe.getRotations()), 32, 0, Color.gray.getRGB());
this.icon.draw(matrixStack, 29, 8);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull SpinningWhee
@Override
public void draw(SpinningWheelRecipe recipe, @Nonnull MatrixStack matrixStack, double mouseX, double mouseY) {
Minecraft mc = Minecraft.getInstance();
mc.fontRenderer.func_243246_a(matrixStack, new TranslationTextComponent("gui.atum.rotations", recipe.getRotations()), 25, 0, Color.gray.getRGB());
mc.fontRenderer.func_243248_b(matrixStack, new TranslationTextComponent("gui.atum.rotations", recipe.getRotations()), 25, 0, Color.gray.getRGB());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@

import javax.annotation.Nonnull;
import java.util.EnumSet;
import java.util.Optional;
import java.util.Set;

public class AtemsHomecomingItem extends AmuletItem { //TODO Test if works
public class AtemsHomecomingItem extends AmuletItem {

public AtemsHomecomingItem() {
super(new Item.Properties().maxDamage(20));
Expand All @@ -36,8 +35,7 @@ public ActionResult<ItemStack> onItemRightClick(@Nonnull World world, PlayerEnti
ServerWorld serverWorld = (ServerWorld) world;
if (player instanceof ServerPlayerEntity) {
ServerPlayerEntity serverPlayer = (ServerPlayerEntity) player;
Optional<Vector3d> optional = PlayerEntity.func_242374_a(serverWorld, serverPlayer.func_241140_K_(), serverPlayer.func_242109_L(), serverPlayer.func_241142_M_(), false);
pos = optional.isPresent() ? new BlockPos(optional.get()) : null;
pos = serverPlayer.func_241140_K_(); //Bed pos
if (pos == null) {
BlockPos spawnPointPos = serverWorld.getSpawnPoint();
while (spawnPointPos.getY() > 1 && world.isAirBlock(spawnPointPos)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ protected ArrowEntity setArrow(@Nonnull ItemStack stack, World world, PlayerEnti

@Override
protected void onShoot(ArrowEntity arrow, PlayerEntity player, float velocity) {
arrow.shoot(player.rotationPitch, player.rotationYaw, 0.0F, velocity * 2.0F, 0.0F);
arrow.func_234612_a_(player, player.rotationPitch, player.rotationYaw, 0.0F, velocity * 2.0F, 0.0F);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ protected CustomArrow setArrow(@Nonnull ItemStack stack, World world, PlayerEnti

@Override
protected void onShoot(ArrowEntity arrow, PlayerEntity player, float velocity) {
arrow.shoot(player.rotationPitch, player.rotationYaw, 0.0F, velocity * 2.5F, 0.0F);
arrow.func_234612_a_(player, player.rotationPitch, player.rotationYaw, 0.0F, velocity * 2.5F, 0.0F);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected void onVelocity(World world, PlayerEntity player, float velocity) {
}

protected void onShoot(ArrowEntity arrow, PlayerEntity player, float velocity) {
arrow.shoot(player.rotationPitch, player.rotationYaw, 0.0F, velocity * 3.0F, 1.0F);
arrow.func_234612_a_(player, player.rotationPitch, player.rotationYaw, 0.0F, velocity * 3.0F, 1.0F);
}

public float getDrawbackSpeed(@Nonnull ItemStack stack, LivingEntity entity) {
Expand Down

0 comments on commit d7c4497

Please sign in to comment.