mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 02:45:13 +00:00
Fix a bunch of todos and misc bugs
This commit is contained in:
1 parent
2e852ab24e
commit
ff975fbded
9 files changed
+62
-35
No files matched your search
@@ -9,10 +9,7 @@
|
||||
* File Created @ [17/11/2015, 20:10:53 (GMT)]
|
||||
*/
|
||||
package vazkii.botania.api.item;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import vazkii.botania.api.subtile.SubTileEntity;
|
||||
|
||||
/**
|
||||
@@ -24,5 +21,5 @@ public interface IFlowerPlaceable {
|
||||
* @param ctx The placement context, aiming downwards towards the downward neighbor position
|
||||
* @return Whether the block was placed successfully
|
||||
*/
|
||||
boolean tryPlace(SubTileEntity flower, ItemUseContext ctx);
|
||||
boolean tryPlace(SubTileEntity flower, BlockItemUseContext ctx);
|
||||
}
|
||||
@@ -63,7 +63,13 @@ public final class ColorHandler {
|
||||
float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
|
||||
return Color.HSBtoRGB(time * 0.005F, 0.6F, 1F);
|
||||
} else {
|
||||
return state.get(BotaniaStateProps.COLOR).colorValue;
|
||||
if(world != null && pos != null) {
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if(te instanceof TilePool) {
|
||||
return ((TilePool) te).color.colorValue;
|
||||
}
|
||||
}
|
||||
return EnumDyeColor.WHITE.colorValue;
|
||||
}
|
||||
},
|
||||
ModBlocks.manaPool, ModBlocks.creativePool, ModBlocks.dilutedPool, ModBlocks.fabulousPool
|
||||
|
||||
@@ -139,9 +139,6 @@ public class Botania {
|
||||
|
||||
BotaniaAPI.internalHandler = new InternalMethodHandler();
|
||||
|
||||
// todo 1.13 remove when event is fired
|
||||
ColorHelper.idShift(new FMLModIdMappingEvent(Collections.emptyMap(), false));
|
||||
|
||||
PacketHandler.init();
|
||||
ModBrews.init();
|
||||
ModMultiblocks.init();
|
||||
|
||||
@@ -63,17 +63,9 @@ public class BlockPool extends BlockMod implements IWandHUD, IWandable, ILexicon
|
||||
|
||||
public BlockPool(Variant v, Properties builder) {
|
||||
super(builder);
|
||||
setDefaultState(stateContainer.getBaseState()
|
||||
.with(BotaniaStateProps.COLOR, EnumDyeColor.WHITE));
|
||||
this.variant = v;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder) {
|
||||
// todo 1.13 move to extended state replacement
|
||||
builder.add(BotaniaStateProps.COLOR);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public VoxelShape getShape(IBlockState state, IBlockReader world, BlockPos pos) {
|
||||
|
||||
@@ -11,8 +11,10 @@
|
||||
package vazkii.botania.common.block.subtile.functional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -40,15 +42,16 @@ public class SubTileExoflame extends SubTileFunctional {
|
||||
|
||||
for(BlockPos pos : BlockPos.getAllInBox(getPos().add(-RANGE, -RANGE_Y, -RANGE), getPos().add(RANGE, RANGE_Y, RANGE))) {
|
||||
TileEntity tile = supertile.getWorld().getTileEntity(pos);
|
||||
Block block = supertile.getWorld().getBlockState(pos).getBlock();
|
||||
IBlockState state = supertile.getWorld().getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
if(tile != null) {
|
||||
if(tile instanceof TileEntityFurnace && block == Blocks.FURNACE) {
|
||||
TileEntityFurnace furnace = (TileEntityFurnace) tile;
|
||||
boolean canSmelt = canFurnaceSmelt(furnace);
|
||||
if(canSmelt && mana > 2) {
|
||||
if(furnace.getField(0) < 2) { // Field 0 -> Burn time
|
||||
/*if(furnace.getField(0) == 0) todo 1.13 check if necessary now
|
||||
BlockFurnace.setState(true, supertile.getWorld(), pos);*/
|
||||
if(furnace.getField(0) == 0)
|
||||
supertile.getWorld().setBlockState(pos, state.with(BlockStateProperties.LIT, true));
|
||||
furnace.setField(0, 200);
|
||||
mana = Math.max(0, mana - COST);
|
||||
}
|
||||
|
||||
+35
-5
@@ -16,6 +16,8 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -27,6 +29,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -42,7 +45,11 @@ import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
@@ -78,21 +85,20 @@ public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
if(stackItem instanceof ItemBlock || stackItem instanceof IFlowerPlaceable) {
|
||||
if(!validPositions.isEmpty()) {
|
||||
BlockPos coords = validPositions.get(supertile.getWorld().rand.nextInt(validPositions.size()));
|
||||
ItemUseContext ctx = new ItemUseContext(supertile.getWorld(), null, stack, coords, EnumFacing.UP, 0, 0, 0);
|
||||
BlockItemUseContext ctx = new RannuncarpusPlaceContext(supertile.getWorld(), stack, coords, EnumFacing.UP, 0, 0, 0);
|
||||
|
||||
boolean success = false;
|
||||
if(stackItem instanceof IFlowerPlaceable) {
|
||||
success = ((IFlowerPlaceable) stackItem).tryPlace(this, ctx);
|
||||
} if(stackItem instanceof ItemBlock) {
|
||||
success = stack.onItemUse(ctx) == EnumActionResult.SUCCESS;
|
||||
success = ((ItemBlock) stackItem).tryPlace(ctx) == EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
if(success) {
|
||||
/* todo 1.13 no easy way to find out where it eventually got placed
|
||||
if(ConfigHandler.COMMON.blockBreakParticles.get()) {
|
||||
supertile.getWorld().playEvent(2001, coords, Block.getStateId(stateToPlace));
|
||||
IBlockState state = supertile.getWorld().getBlockState(ctx.getPos());
|
||||
supertile.getWorld().playEvent(2001, coords, Block.getStateId(state));
|
||||
}
|
||||
*/
|
||||
validPositions.remove(coords);
|
||||
if(mana > 1)
|
||||
mana--;
|
||||
@@ -187,4 +193,28 @@ public class SubTileRannuncarpus extends SubTileFunctional {
|
||||
@Override public int getRangeY() { return RANGE_PLACE_Y_MINI; }
|
||||
}
|
||||
|
||||
// BlockItemUseContext uses a nullable player field without checking it -.-
|
||||
private static class RannuncarpusPlaceContext extends BlockItemUseContext {
|
||||
private final EnumFacing[] lookDirs;
|
||||
|
||||
public RannuncarpusPlaceContext(World world, ItemStack stack, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
super(world, null, stack, pos, side, hitX, hitY, hitZ);
|
||||
List<EnumFacing> tmp = Arrays.asList(EnumFacing.values());
|
||||
Collections.shuffle(tmp);
|
||||
lookDirs = tmp.toArray(new EnumFacing[6]);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumFacing getNearestLookingDirection() {
|
||||
return getNearestLookingDirections()[0];
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EnumFacing[] getNearestLookingDirections() {
|
||||
return lookDirs;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -492,7 +492,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
|
||||
@Override
|
||||
public void setColor(EnumDyeColor color) {
|
||||
this.color = color;
|
||||
world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 0b1011);
|
||||
world.notifyBlockUpdate(pos, getBlockState(), getBlockState(), 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.ColorHelper;
|
||||
import vazkii.botania.api.mana.IManaPool;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.item.Item16Colors;
|
||||
@@ -77,19 +78,20 @@ public class ItemDye extends Item16Colors {
|
||||
return false;
|
||||
}
|
||||
|
||||
// todo 1.13 yikes is there a better way?
|
||||
private boolean shouldRecolor(Block block) {
|
||||
if (block.getRegistryName().getNamespace().equals("minecraft")
|
||||
&& (block.getRegistryName().getPath().contains("_carpet")
|
||||
|| block.getRegistryName().getPath().contains("_wool"))) {
|
||||
String blockColor = block.getRegistryName().getPath().split("_")[0];
|
||||
return !blockColor.equals(this.color.getName());
|
||||
}
|
||||
EnumDyeColor woolColor = ColorHelper.WOOL_MAP.inverse().get(block);
|
||||
if(woolColor != null)
|
||||
return woolColor != this.color;
|
||||
|
||||
EnumDyeColor carpetColor = ColorHelper.CARPET_MAP.inverse().get(block);
|
||||
if(carpetColor != null)
|
||||
return carpetColor != this.color;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private IBlockState recolor(Block original, EnumDyeColor color) {
|
||||
if (original.getRegistryName().getPath().contains("_carpet")) {
|
||||
if (ColorHelper.CARPET_MAP.values().contains(original)) {
|
||||
return ModBlocks.getCarpet(color).getDefaultState();
|
||||
} else {
|
||||
return ModBlocks.getWool(color).getDefaultState();
|
||||
|
||||
Reference in new issue
Block a user