mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Misc todo fixes in enchanter, tiny potato, avatar
This commit is contained in:
1 parent
5713b91177
commit
c29640e558
3 files changed
+41
-24
No files matched your search
@@ -66,8 +66,7 @@ public class RenderTileTinyPotato extends TileEntityRenderer<TileTinyPotato> {
|
||||
|
||||
@Override
|
||||
public void render(@Nonnull TileTinyPotato potato, double x, double y, double z, float partialTicks, int destroyStage) {
|
||||
if(!potato.getWorld().isBlockLoaded(potato.getPos(), false)
|
||||
|| potato.getWorld().getBlockState(potato.getPos()).getBlock() != ModBlocks.tinyPotato)
|
||||
if(potato.getBlockState().getBlock() != ModBlocks.tinyPotato)
|
||||
return;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
@@ -104,9 +103,16 @@ public class RenderTileTinyPotato extends TileEntityRenderer<TileTinyPotato> {
|
||||
|
||||
GlStateManager.translatef(0.5F, 1.5F, 0.5F);
|
||||
GlStateManager.scalef(1F, -1F, -1F);
|
||||
int meta = potato.getBlockState().get(BotaniaStateProps.CARDINALS).getHorizontalIndex();
|
||||
float rotY = meta * 90F - 180F;
|
||||
GlStateManager.rotatef(rotY, 0F, 1F, 0F); // todo 1.13 recheck
|
||||
EnumFacing potatoFacing = potato.getBlockState().get(BotaniaStateProps.CARDINALS);
|
||||
float rotY = 0;
|
||||
switch(potatoFacing) {
|
||||
default:
|
||||
case SOUTH: break;
|
||||
case NORTH: rotY = 180F; break;
|
||||
case EAST: rotY = 270F; break;
|
||||
case WEST: rotY = 90F; break;
|
||||
}
|
||||
GlStateManager.rotatef(rotY, 0F, 1F, 0F);
|
||||
|
||||
float jump = potato.jumpTicks;
|
||||
if (jump > 0)
|
||||
@@ -159,8 +165,6 @@ public class RenderTileTinyPotato extends TileEntityRenderer<TileTinyPotato> {
|
||||
float s = 1F / 3.5F;
|
||||
GlStateManager.scalef(s, s, s);
|
||||
|
||||
EnumFacing potatoFacing = potato.getWorld().getBlockState(potato.getPos()).get(BotaniaStateProps.CARDINALS);
|
||||
|
||||
for(int i = 0; i < potato.getSizeInventory(); i++) {
|
||||
ItemStack stack = potato.getItemHandler().getStackInSlot(i);
|
||||
if(stack.isEmpty())
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.StateContainer;
|
||||
@@ -24,6 +25,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.Mirror;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
@@ -46,6 +49,7 @@ import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockAvatar extends BlockMod implements ILexiconable {
|
||||
|
||||
@@ -89,17 +93,17 @@ public class BlockAvatar extends BlockMod implements ILexiconable {
|
||||
|
||||
@Override
|
||||
public void onReplaced(@Nonnull IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState newstate, boolean isMoving) {
|
||||
TileSimpleInventory inv = (TileSimpleInventory) world.getTileEntity(pos);
|
||||
|
||||
InventoryHelper.dropInventory(inv, world, state, pos);
|
||||
|
||||
super.onReplaced(state, world, pos, newstate, isMoving);
|
||||
if(state.getBlock() != newstate.getBlock()) {
|
||||
TileSimpleInventory inv = (TileSimpleInventory) world.getTileEntity(pos);
|
||||
InventoryHelper.dropInventory(inv, world, state, pos);
|
||||
super.onReplaced(state, world, pos, newstate, isMoving);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
|
||||
// todo 1.13 getstateforplacement
|
||||
world.setBlockState(pos, state.with(BotaniaStateProps.CARDINALS, placer.getHorizontalFacing().getOpposite()));
|
||||
public IBlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return getDefaultState().with(BotaniaStateProps.CARDINALS, context.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,4 +139,15 @@ public class BlockAvatar extends BlockMod implements ILexiconable {
|
||||
return LexiconData.avatar;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState mirror(@Nonnull IBlockState state, Mirror mirror) {
|
||||
return state.with(BotaniaStateProps.CARDINALS, mirror.mirror(state.get(BotaniaStateProps.CARDINALS)));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBlockState rotate(@Nonnull IBlockState state, Rotation rot) {
|
||||
return state.with(BotaniaStateProps.CARDINALS, rot.rotate(state.get(BotaniaStateProps.CARDINALS)));
|
||||
}
|
||||
}
|
||||
@@ -143,11 +143,10 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
|
||||
for(EntityItem entity : items) {
|
||||
ItemStack item = entity.getItem();
|
||||
if(item.getItem() == Items.ENCHANTED_BOOK) {
|
||||
NBTTagList enchants = ItemEnchantedBook.getEnchantments(item);
|
||||
Map<Enchantment, Integer> enchants = EnchantmentHelper.getEnchantments(item);
|
||||
if(enchants.size() > 0) {
|
||||
NBTTagCompound enchant = enchants.getCompound(0); // todo 1.13 update
|
||||
short id = enchant.getShort("id");
|
||||
if(isEnchantmentValid(Enchantment.getEnchantmentByID(id))) {
|
||||
Enchantment enchant = enchants.keySet().iterator().next();
|
||||
if(isEnchantmentValid(enchant)) {
|
||||
advanceStage();
|
||||
return;
|
||||
}
|
||||
@@ -165,12 +164,11 @@ public class TileEnchanter extends TileMod implements ISparkAttachable, ITickabl
|
||||
for(EntityItem entity : items) {
|
||||
ItemStack item = entity.getItem();
|
||||
if(item.getItem() == Items.ENCHANTED_BOOK) {
|
||||
NBTTagList enchants = ItemEnchantedBook.getEnchantments(item);
|
||||
Map<Enchantment, Integer> enchants = EnchantmentHelper.getEnchantments(item);
|
||||
if(enchants.size() > 0) {
|
||||
NBTTagCompound enchant = enchants.getCompound(0);
|
||||
short enchantId = enchant.getShort("id");
|
||||
short enchantLvl = enchant.getShort("lvl");
|
||||
Enchantment ench = Enchantment.getEnchantmentByID(enchantId);
|
||||
Map.Entry<Enchantment, Integer> e = enchants.entrySet().iterator().next();
|
||||
Enchantment ench = e.getKey();
|
||||
int enchantLvl = e.getValue();
|
||||
if(!hasEnchantAlready(ench) && isEnchantmentValid(ench)) {
|
||||
this.enchants.add(new EnchantmentData(ench, enchantLvl));
|
||||
world.playSound(null, pos, ModSounds.ding, SoundCategory.BLOCKS, 1F, 1F);
|
||||
|
||||
Reference in new issue
Block a user