mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 10:55:17 +00:00
bump forge to rb, fix fluid stuff
This commit is contained in:
1 parent
bd8ce05831
commit
3c2de8453e
21 files changed
+138
-121
No files matched your search
-1
@@ -23,7 +23,6 @@ import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import vazkii.botania.api.recipe.RecipePureDaisy;
|
||||
import vazkii.botania.common.block.ModSubtiles;
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
@@ -103,7 +104,6 @@ public class RenderTileAltar extends TileEntityRenderer<TileAltar> {
|
||||
|
||||
|
||||
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||
int brightness = lava ? 240 : -1;
|
||||
float alpha = lava ? 1F : 0.7F;
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
@@ -118,7 +118,9 @@ public class RenderTileAltar extends TileEntityRenderer<TileAltar> {
|
||||
|
||||
TextureAtlasSprite sprite = lava ? Minecraft.getInstance().getModelManager().getBlockModelShapes().getModel(Blocks.LAVA.getDefaultState()).getParticleTexture()
|
||||
: Minecraft.getInstance().getModelManager().getBlockModelShapes().getModel(Blocks.WATER.getDefaultState()).getParticleTexture();
|
||||
renderIcon(0, 0, sprite, 16, 16, brightness);
|
||||
int color = lava ? Fluids.LAVA.getAttributes().getColor(altar.getWorld(), altar.getPos())
|
||||
: Fluids.WATER.getAttributes().getColor(altar.getWorld(), altar.getPos());
|
||||
renderIcon(sprite, color, alpha);
|
||||
if(lava)
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.enableAlphaTest();
|
||||
@@ -128,15 +130,16 @@ public class RenderTileAltar extends TileEntityRenderer<TileAltar> {
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
private void renderIcon(int x, int y, TextureAtlasSprite sprite, int width, int height, int brightness) {
|
||||
private void renderIcon(TextureAtlasSprite sprite, int color, float alpha) {
|
||||
int red = ((color >> 16) & 0xFF);
|
||||
int green = ((color >> 8) & 0xFF);
|
||||
int blue = (color & 0xFF);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||
//if(brightness != -1)
|
||||
//tessellator.getBuffer().putBrightness4(brightness, brightness, brightness, brightness);
|
||||
tessellator.getBuffer().pos(x + 0, y + height, 0).tex(sprite.getMinU(), sprite.getMaxV()).endVertex();
|
||||
tessellator.getBuffer().pos(x + width, y + height, 0).tex(sprite.getMaxU(), sprite.getMaxV()).endVertex();
|
||||
tessellator.getBuffer().pos(x + width, y + 0, 0).tex(sprite.getMaxU(), sprite.getMinV()).endVertex();
|
||||
tessellator.getBuffer().pos(x + 0, y + 0, 0).tex(sprite.getMinU(), sprite.getMinV()).endVertex();
|
||||
tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
tessellator.getBuffer().pos(0, 16, 0).tex(sprite.getMinU(), sprite.getMaxV()).color(red, green, blue, (int) (alpha * 255F)).endVertex();
|
||||
tessellator.getBuffer().pos(16, 16, 0).tex(sprite.getMaxU(), sprite.getMaxV()).color(red, green, blue, (int) (alpha * 255F)).endVertex();
|
||||
tessellator.getBuffer().pos(16, 0, 0).tex(sprite.getMaxU(), sprite.getMinV()).color(red, green, blue, (int) (alpha * 255F)).endVertex();
|
||||
tessellator.getBuffer().pos(0, 0, 0).tex(sprite.getMinU(), sprite.getMinV()).color(red, green, blue, (int) (alpha * 255F)).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ import vazkii.botania.common.core.loot.LootHandler;
|
||||
import vazkii.botania.common.core.loot.TrueGuardianKiller;
|
||||
import vazkii.botania.common.core.proxy.IProxy;
|
||||
import vazkii.botania.common.core.proxy.ServerProxy;
|
||||
import vazkii.botania.common.crafting.FluxfieldConditionFactory;
|
||||
import vazkii.botania.common.crafting.FluxfieldCondition;
|
||||
import vazkii.botania.common.crafting.ReloadListener;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
@@ -144,7 +144,7 @@ public class Botania {
|
||||
CriteriaTriggers.register(RelicBindTrigger.INSTANCE);
|
||||
CriteriaTriggers.register(UseItemSuccessTrigger.INSTANCE);
|
||||
|
||||
CraftingHelper.register(FluxfieldConditionFactory.KEY, new FluxfieldConditionFactory());
|
||||
CraftingHelper.register(FluxfieldCondition.SERIALIZER);
|
||||
|
||||
ModBlocks.addDispenserBehaviours();
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -31,7 +33,7 @@ import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IEnviromentBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
@@ -129,7 +131,7 @@ public class BlockAltar extends BlockMod implements ILexiconable {
|
||||
if(stack.getItem() == ModItems.waterRod)
|
||||
ManaItemHandler.requestManaExact(stack, player, ItemWaterRod.COST, true);
|
||||
else if(!player.abilities.isCreativeMode)
|
||||
player.setHeldItem(hand, new ItemStack(Items.BUCKET) /* todo 1.13 drain(FluidRegistry.WATER, stack) */);
|
||||
player.setHeldItem(hand, drain(Fluids.WATER, stack));
|
||||
|
||||
tile.setWater(true);
|
||||
world.updateComparatorOutputLevel(pos, this);
|
||||
@@ -139,7 +141,7 @@ public class BlockAltar extends BlockMod implements ILexiconable {
|
||||
return true;
|
||||
} else if(!stack.isEmpty() && stack.getItem() == Items.LAVA_BUCKET) {
|
||||
if(!player.abilities.isCreativeMode)
|
||||
player.setHeldItem(hand, new ItemStack(Items.BUCKET) /* todo 1.13 drain(FluidRegistry.LAVA, stack) */);
|
||||
player.setHeldItem(hand, drain(Fluids.LAVA, stack));
|
||||
|
||||
tile.setLava(true);
|
||||
tile.setWater(false);
|
||||
@@ -186,23 +188,16 @@ public class BlockAltar extends BlockMod implements ILexiconable {
|
||||
if(stack.isEmpty() || stack.getCount() != 1)
|
||||
return false;
|
||||
|
||||
LazyOptional<IFluidHandlerItem> cap = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY);
|
||||
if(cap.isPresent()) {
|
||||
IFluidHandler handler = cap.orElseThrow(IllegalStateException::new);
|
||||
/* todo 1.13
|
||||
FluidStack simulate = handler.drain(new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME), false);
|
||||
if(simulate != null && simulate.getFluid() == FluidRegistry.WATER && simulate.amount == Fluid.BUCKET_VOLUME)
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
return false;
|
||||
return stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY).map(handler -> {
|
||||
FluidStack simulate = handler.drain(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.SIMULATE);
|
||||
return !simulate.isEmpty() && simulate.getFluid() == Fluids.WATER && simulate.getAmount() == FluidAttributes.BUCKET_VOLUME;
|
||||
}).orElse(false);
|
||||
}
|
||||
|
||||
private ItemStack drain(Fluid fluid, ItemStack stack) {
|
||||
return stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY)
|
||||
.map(handler -> {
|
||||
handler.drain(new FluidStack(fluid, Fluid.BUCKET_VOLUME), true);
|
||||
handler.drain(new FluidStack(fluid, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.EXECUTE);
|
||||
return handler.getContainer();
|
||||
})
|
||||
.orElse(stack);
|
||||
|
||||
@@ -164,7 +164,7 @@ public class SubTileLoonuim extends TileEntityFunctionalFlower {
|
||||
entity instanceof CreeperEntity ? 100 : Integer.MAX_VALUE, 0));
|
||||
|
||||
CompoundNBT cmp = stack.write(new CompoundNBT());
|
||||
entity.getEntityData().put(TAG_ITEMSTACK_TO_DROP, cmp);
|
||||
entity.getPersistentData().put(TAG_ITEMSTACK_TO_DROP, cmp);
|
||||
|
||||
entity.onInitialSpawn(world, world.getDifficultyForLocation(pos), SpawnReason.SPAWNER, null, null);
|
||||
world.addEntity(entity);
|
||||
@@ -216,8 +216,8 @@ public class SubTileLoonuim extends TileEntityFunctionalFlower {
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public static void onDrops(LivingDropsEvent event) {
|
||||
LivingEntity e = event.getEntityLiving();
|
||||
if(e.getEntityData().contains(TAG_ITEMSTACK_TO_DROP)) {
|
||||
CompoundNBT cmp = e.getEntityData().getCompound(TAG_ITEMSTACK_TO_DROP);
|
||||
if(e.getPersistentData().contains(TAG_ITEMSTACK_TO_DROP)) {
|
||||
CompoundNBT cmp = e.getPersistentData().getCompound(TAG_ITEMSTACK_TO_DROP);
|
||||
ItemStack stack = ItemStack.read(cmp);
|
||||
event.getDrops().clear();
|
||||
event.getDrops().add(new ItemEntity(e.world, e.posX, e.posY, e.posZ, stack));
|
||||
|
||||
+3
-3
@@ -51,7 +51,7 @@ public class SubTileSpectranthemum extends TileEntityFunctionalFlower {
|
||||
private static final int RANGE = 2;
|
||||
private static final int BIND_RANGE = 12;
|
||||
|
||||
private static final String TAG_TELEPORTED = "Botania_TPd";
|
||||
private static final String TAG_TELEPORTED = "botania:teleported";
|
||||
|
||||
private BlockPos bindPos = new BlockPos(0, -1, 0);
|
||||
|
||||
@@ -72,7 +72,7 @@ public class SubTileSpectranthemum extends TileEntityFunctionalFlower {
|
||||
int slowdown = getSlowdownFactor();
|
||||
|
||||
for(ItemEntity item : items) {
|
||||
if(item.age < 60 + slowdown || !item.isAlive() || item.getEntityData().getBoolean(TAG_TELEPORTED))
|
||||
if(item.age < 60 + slowdown || !item.isAlive() || item.getPersistentData().getBoolean(TAG_TELEPORTED))
|
||||
continue;
|
||||
|
||||
ItemStack stack = item.getItem();
|
||||
@@ -85,7 +85,7 @@ public class SubTileSpectranthemum extends TileEntityFunctionalFlower {
|
||||
if(mana >= cost) {
|
||||
spawnExplosionParticles(item, 10);
|
||||
item.setPosition(bindPos.getX() + 0.5, bindPos.getY() + 1.5, bindPos.getZ() + 0.5);
|
||||
item.getEntityData().putBoolean(TAG_TELEPORTED, true);
|
||||
item.getPersistentData().putBoolean(TAG_TELEPORTED, true);
|
||||
item.setMotion(Vec3d.ZERO);
|
||||
spawnExplosionParticles(item, 10);
|
||||
mana -= cost;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SubTileNarslimmus extends TileEntityGeneratingFlower {
|
||||
@ObjectHolder(LibMisc.MOD_ID + ":narslimmus")
|
||||
public static TileEntityType<SubTileNarslimmus> TYPE;
|
||||
|
||||
public static final String TAG_WORLD_SPAWNED = "Botania:WorldSpawned";
|
||||
public static final String TAG_WORLD_SPAWNED = "botania:world_spawned";
|
||||
|
||||
private static final int RANGE = 2;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class SubTileNarslimmus extends TileEntityGeneratingFlower {
|
||||
if(ticksExisted % 5 == 0) {
|
||||
List<SlimeEntity> slimes = getWorld().getEntitiesWithinAABB(SlimeEntity.class, new AxisAlignedBB(getPos().add(-RANGE, -RANGE, -RANGE), getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
|
||||
for(SlimeEntity slime : slimes) {
|
||||
if(slime.getEntityData().getBoolean(TAG_WORLD_SPAWNED) && slime.isAlive()) {
|
||||
if(slime.getPersistentData().getBoolean(TAG_WORLD_SPAWNED) && slime.isAlive()) {
|
||||
int size = slime.getSlimeSize();
|
||||
int mul = (int) Math.pow(2, size);
|
||||
int mana = 1200 * mul;
|
||||
@@ -105,7 +105,7 @@ public class SubTileNarslimmus extends TileEntityGeneratingFlower {
|
||||
if(event.getEntityLiving() instanceof SlimeEntity
|
||||
&& event.getResult() != Event.Result.DENY
|
||||
&& isSlimeChunk(event.getEntityLiving().world, event.getX(), event.getZ()))
|
||||
event.getEntityLiving().getEntityData().putBoolean(TAG_WORLD_SPAWNED, true);
|
||||
event.getEntityLiving().getPersistentData().putBoolean(TAG_WORLD_SPAWNED, true);
|
||||
}
|
||||
|
||||
private static boolean isSlimeChunk(World world, double x, double z) {
|
||||
|
||||
@@ -149,7 +149,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
|
||||
ItemStack stack = item.getItem();
|
||||
boolean consume;
|
||||
if (item.getEntityData().contains(TAG_PORTAL_FLAG)) {
|
||||
if (item.getPersistentData().contains(TAG_PORTAL_FLAG)) {
|
||||
consume = false;
|
||||
} else if (stack.getItem() instanceof ItemLexicon) {
|
||||
consume = true;
|
||||
@@ -277,7 +277,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
|
||||
|
||||
private void spawnItem(ItemStack stack) {
|
||||
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, stack);
|
||||
item.getEntityData().putBoolean(TAG_PORTAL_FLAG, true);
|
||||
item.getPersistentData().putBoolean(TAG_PORTAL_FLAG, true);
|
||||
world.addEntity(item);
|
||||
ticksSinceLastItem = 0;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.particles.ParticleTypes;
|
||||
@@ -35,10 +37,10 @@ import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -115,26 +117,24 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
|
||||
|
||||
if(!hasWater() && !hasLava()) {
|
||||
if(hasFluidCapability) {
|
||||
/* todo 1.13
|
||||
IFluidHandlerItem fluidHandler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
|
||||
IFluidHandlerItem fluidHandler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY).orElseThrow(NullPointerException::new);
|
||||
|
||||
FluidStack drainWater = fluidHandler.drain(new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME), false);
|
||||
FluidStack drainLava = fluidHandler.drain(new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME), false);
|
||||
FluidStack drainWater = fluidHandler.drain(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.SIMULATE);
|
||||
FluidStack drainLava = fluidHandler.drain(new FluidStack(Fluids.LAVA, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.SIMULATE);
|
||||
|
||||
if(drainWater != null && drainWater.getFluid() == FluidRegistry.WATER && drainWater.amount == Fluid.BUCKET_VOLUME) {
|
||||
if(!drainWater.isEmpty() && drainWater.getFluid() == Fluids.WATER && drainWater.getAmount() == FluidAttributes.BUCKET_VOLUME) {
|
||||
setWater(true);
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
fluidHandler.drain(new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME), true);
|
||||
fluidHandler.drain(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.EXECUTE);
|
||||
item.setItem(fluidHandler.getContainer());
|
||||
return true;
|
||||
} else if(drainLava != null && drainLava.getFluid() == FluidRegistry.LAVA && drainLava.amount == Fluid.BUCKET_VOLUME) {
|
||||
} else if(!drainLava.isEmpty() && drainLava.getFluid() == Fluids.LAVA && drainLava.getAmount() == FluidAttributes.BUCKET_VOLUME) {
|
||||
setLava(true);
|
||||
world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
|
||||
fluidHandler.drain(new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME), true);
|
||||
fluidHandler.drain(new FluidStack(Fluids.LAVA, FluidAttributes.BUCKET_VOLUME), IFluidHandler.FluidAction.EXECUTE);
|
||||
item.setItem(fluidHandler.getContainer());
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* This class was created by <williewillus>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.common.crafting;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
import net.minecraftforge.common.crafting.conditions.IConditionSerializer;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class FluxfieldCondition implements ICondition {
|
||||
public static final ResourceLocation KEY = new ResourceLocation(LibMisc.MOD_ID, "fluxfield_enabled");
|
||||
private final boolean value;
|
||||
|
||||
public FluxfieldCondition(boolean value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test() {
|
||||
return ConfigHandler.COMMON.fluxfieldEnabled.get() == value;
|
||||
}
|
||||
|
||||
public static final IConditionSerializer<FluxfieldCondition> SERIALIZER = new IConditionSerializer<FluxfieldCondition>() {
|
||||
@Override
|
||||
public void write(JsonObject json, FluxfieldCondition cond) {
|
||||
json.addProperty("value", cond.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluxfieldCondition read(JsonObject json) {
|
||||
return new FluxfieldCondition(json.get("value").getAsBoolean());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID() {
|
||||
return KEY;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* This class was created by <williewillus>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.common.crafting;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.IConditionSerializer;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
public class FluxfieldConditionFactory implements IConditionSerializer {
|
||||
public static final ResourceLocation KEY = new ResourceLocation(LibMisc.MOD_ID, "fluxfield_enabled");
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BooleanSupplier parse(@Nonnull JsonObject json) {
|
||||
boolean value = JSONUtils.getBoolean(json , "value", true);
|
||||
return () -> ConfigHandler.COMMON.fluxfieldEnabled.get() == value;
|
||||
}
|
||||
}
|
||||
@@ -485,7 +485,7 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst {
|
||||
|
||||
currentPos = Vector3.fromEntity(this);
|
||||
diffVec = oldPos.subtract(currentPos);
|
||||
if(getEntityData().contains(ItemTinyPlanet.TAG_ORBIT))
|
||||
if(getPersistentData().contains(ItemTinyPlanet.TAG_ORBIT))
|
||||
break;
|
||||
} while(Math.abs(diffVec.mag()) > distance);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ItemKeepIvy extends ItemMod {
|
||||
i++;
|
||||
}
|
||||
|
||||
CompoundNBT data = event.getEntityLiving().getEntityData();
|
||||
CompoundNBT data = event.getEntityLiving().getPersistentData();
|
||||
if(!data.contains(PlayerEntity.PERSISTED_NBT_TAG))
|
||||
data.put(PlayerEntity.PERSISTED_NBT_TAG, new CompoundNBT());
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ItemKeepIvy extends ItemMod {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPlayerRespawn(PlayerEvent.PlayerRespawnEvent event) {
|
||||
CompoundNBT data = event.getPlayer().getEntityData();
|
||||
CompoundNBT data = event.getPlayer().getPersistentData();
|
||||
if(data.contains(PlayerEntity.PERSISTED_NBT_TAG)) {
|
||||
CompoundNBT cmp = data.getCompound(PlayerEntity.PERSISTED_NBT_TAG);
|
||||
CompoundNBT cmp1 = cmp.getCompound(TAG_PLAYER_KEPT_DROPS);
|
||||
@@ -94,7 +94,7 @@ public class ItemKeepIvy extends ItemMod {
|
||||
}
|
||||
}
|
||||
|
||||
cmp.put(TAG_PLAYER_KEPT_DROPS, new CompoundNBT());
|
||||
cmp.remove(TAG_PLAYER_KEPT_DROPS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
*/
|
||||
package vazkii.botania.common.item;
|
||||
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStackSimple;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
@@ -29,18 +29,18 @@ public class ItemWaterBowl extends ItemMod {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
/* todo 1.13
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) {
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) {
|
||||
return new Handler(stack);
|
||||
}
|
||||
|
||||
private static class Handler extends FluidHandlerItemStackSimple.SwapEmpty {
|
||||
|
||||
private Handler(ItemStack stack) {
|
||||
super(stack, new ItemStack(Items.BOWL), Fluid.BUCKET_VOLUME);
|
||||
setFluid(new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME));
|
||||
super(stack, new ItemStack(Items.BOWL), FluidAttributes.BUCKET_VOLUME);
|
||||
setFluid(new FluidStack(Fluids.WATER, FluidAttributes.BUCKET_VOLUME));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,9 +50,8 @@ public class ItemWaterBowl extends ItemMod {
|
||||
|
||||
@Override
|
||||
public boolean canDrainFluidType(FluidStack fluid) {
|
||||
return fluid.getFluid() == FluidRegistry.WATER;
|
||||
return fluid.getFluid() == Fluids.WATER;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -87,14 +87,14 @@ public class ItemTinyPlanet extends ItemBauble {
|
||||
}
|
||||
|
||||
public static int getEntityOrbitTime(Entity entity) {
|
||||
CompoundNBT cmp = entity.getEntityData();
|
||||
CompoundNBT cmp = entity.getPersistentData();
|
||||
if(cmp.contains(TAG_ORBIT))
|
||||
return cmp.getInt(TAG_ORBIT);
|
||||
else return 0;
|
||||
}
|
||||
|
||||
public static void incrementOrbitTime(Entity entity) {
|
||||
CompoundNBT cmp = entity.getEntityData();
|
||||
CompoundNBT cmp = entity.getPersistentData();
|
||||
int time = getEntityOrbitTime(entity);
|
||||
cmp.putInt(TAG_ORBIT, time + 1);
|
||||
}
|
||||
|
||||
@@ -20,15 +20,15 @@ import vazkii.botania.common.core.helper.Vector3;
|
||||
|
||||
public class LensMagnet extends Lens {
|
||||
|
||||
private static final String TAG_MAGNETIZED = "Botania:Magnetized";
|
||||
private static final String TAG_MAGNETIZED_X = "Botania:MagnetizedX";
|
||||
private static final String TAG_MAGNETIZED_Y = "Botania:MagnetizedY";
|
||||
private static final String TAG_MAGNETIZED_Z = "Botania:MagnetizedZ";
|
||||
private static final String TAG_MAGNETIZED = "botania:magnetized";
|
||||
private static final String TAG_MAGNETIZED_X = "botania:magnetized_x";
|
||||
private static final String TAG_MAGNETIZED_Y = "botania:magnetized_y";
|
||||
private static final String TAG_MAGNETIZED_Z = "botania:magnetized_z";
|
||||
|
||||
@Override
|
||||
public void updateBurst(IManaBurst burst, ThrowableEntity entity, ItemStack stack) {
|
||||
BlockPos basePos = new BlockPos(entity);
|
||||
boolean magnetized = entity.getEntityData().contains(TAG_MAGNETIZED);
|
||||
boolean magnetized = entity.getPersistentData().contains(TAG_MAGNETIZED);
|
||||
int range = 3;
|
||||
|
||||
magnetize : {
|
||||
@@ -38,9 +38,9 @@ public class LensMagnet extends Lens {
|
||||
TileEntity tile = entity.world.getTileEntity(pos);
|
||||
|
||||
if(magnetized) {
|
||||
int magX = entity.getEntityData().getInt(TAG_MAGNETIZED_X);
|
||||
int magY = entity.getEntityData().getInt(TAG_MAGNETIZED_Y);
|
||||
int magZ = entity.getEntityData().getInt(TAG_MAGNETIZED_Z);
|
||||
int magX = entity.getPersistentData().getInt(TAG_MAGNETIZED_X);
|
||||
int magY = entity.getPersistentData().getInt(TAG_MAGNETIZED_Y);
|
||||
int magZ = entity.getPersistentData().getInt(TAG_MAGNETIZED_Z);
|
||||
if(tile.getPos().getX() != magX || tile.getPos().getY() != magY || tile.getPos().getZ() != magZ)
|
||||
continue;
|
||||
}
|
||||
@@ -61,10 +61,10 @@ public class LensMagnet extends Lens {
|
||||
Vector3 finalMotionVec = motionVec.subtract(differenceVec);
|
||||
if(!magnetized) {
|
||||
finalMotionVec = finalMotionVec.multiply(0.75);
|
||||
entity.getEntityData().putBoolean(TAG_MAGNETIZED, true);
|
||||
entity.getEntityData().putInt(TAG_MAGNETIZED_X, tile.getPos().getX());
|
||||
entity.getEntityData().putInt(TAG_MAGNETIZED_Y, tile.getPos().getY());
|
||||
entity.getEntityData().putInt(TAG_MAGNETIZED_Z, tile.getPos().getZ());
|
||||
entity.getPersistentData().putBoolean(TAG_MAGNETIZED, true);
|
||||
entity.getPersistentData().putInt(TAG_MAGNETIZED_X, tile.getPos().getX());
|
||||
entity.getPersistentData().putInt(TAG_MAGNETIZED_Y, tile.getPos().getY());
|
||||
entity.getPersistentData().putInt(TAG_MAGNETIZED_Z, tile.getPos().getZ());
|
||||
}
|
||||
|
||||
burst.setBurstMotion(finalMotionVec.x, finalMotionVec.y, finalMotionVec.z);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class LensTripwire extends Lens {
|
||||
public boolean allowBurstShooting(ItemStack stack, IManaSpreader spreader, boolean redstone) {
|
||||
IManaBurst burst = spreader.runBurstSimulation();
|
||||
Entity e = (Entity) burst;
|
||||
return e.getEntityData().getBoolean(TAG_TRIPPED);
|
||||
return e.getPersistentData().getBoolean(TAG_TRIPPED);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,7 +41,7 @@ public class LensTripwire extends Lens {
|
||||
List<LivingEntity> entities = entity.world.getEntitiesWithinAABB(LivingEntity.class, axis);
|
||||
if(!entities.isEmpty()) {
|
||||
Entity e = (Entity) burst;
|
||||
e.getEntityData().putBoolean(TAG_TRIPPED, true);
|
||||
e.getPersistentData().putBoolean(TAG_TRIPPED, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class LensWarp extends Lens {
|
||||
entity.setPosition(key.blockPos.getX() + 0.5, key.blockPos.getY() + 0.5, key.blockPos.getZ() + 0.5);
|
||||
burst.setCollidedAt(key.blockPos);
|
||||
|
||||
entity.getEntityData().putBoolean(TAG_WARPED, true);
|
||||
entity.getPersistentData().putBoolean(TAG_WARPED, true);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class LensWarp extends Lens {
|
||||
|
||||
@Override
|
||||
public int getManaToTransfer(IManaBurst burst, ThrowableEntity entity, ItemStack stack, IManaReceiver receiver) {
|
||||
return entity.getEntityData().getBoolean(TAG_WARPED) ? 0 : burst.getMana();
|
||||
return entity.getPersistentData().getBoolean(TAG_WARPED) ? 0 : burst.getMana();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public final class SkyblockWorldEvents {
|
||||
public static void onPlayerUpdate(LivingUpdateEvent event) {
|
||||
if(event.getEntityLiving() instanceof PlayerEntity && !event.getEntityLiving().world.isRemote) {
|
||||
PlayerEntity player = (PlayerEntity) event.getEntityLiving();
|
||||
CompoundNBT data = player.getEntityData();
|
||||
CompoundNBT data = player.getPersistentData();
|
||||
if(!data.contains(PlayerEntity.PERSISTED_NBT_TAG))
|
||||
data.put(PlayerEntity.PERSISTED_NBT_TAG, new CompoundNBT());
|
||||
|
||||
@@ -146,7 +146,7 @@ public final class SkyblockWorldEvents {
|
||||
}
|
||||
|
||||
public static void spawnPlayer(PlayerEntity player, BlockPos pos, boolean fabricated) {
|
||||
CompoundNBT data = player.getEntityData();
|
||||
CompoundNBT data = player.getPersistentData();
|
||||
if(!data.contains(PlayerEntity.PERSISTED_NBT_TAG))
|
||||
data.put(PlayerEntity.PERSISTED_NBT_TAG, new CompoundNBT());
|
||||
CompoundNBT persist = data.getCompound(PlayerEntity.PERSISTED_NBT_TAG);
|
||||
|
||||
Reference in new issue
Block a user