Browse Source

more features, more fixes

pull/193/head
Adrian Siekierka 1 year ago
parent
commit
4e741ad38e
23 changed files with 364 additions and 61 deletions
  1. 9
    2
      src/main/java/pl/asie/charset/lib/block/BlockBase.java
  2. 3
    2
      src/main/java/pl/asie/charset/lib/block/PacketCustomBlockDust.java
  3. 6
    4
      src/main/java/pl/asie/charset/lib/notify/NotifyImplementation.java
  4. 4
    1
      src/main/java/pl/asie/charset/lib/render/model/IStateParticleBakedModel.java
  5. 11
    1
      src/main/java/pl/asie/charset/lib/render/model/ModelFactory.java
  6. 6
    14
      src/main/java/pl/asie/charset/lib/render/sprite/SpritesheetFactory.java
  7. 62
    22
      src/main/java/pl/asie/charset/lib/utils/FluidUtils.java
  8. 4
    0
      src/main/java/pl/asie/charset/lib/utils/ItemUtils.java
  9. 1
    0
      src/main/java/pl/asie/charset/lib/utils/RecipeUtils.java
  10. 23
    2
      src/main/java/pl/asie/charset/lib/utils/UtilProxyClient.java
  11. 7
    1
      src/main/java/pl/asie/charset/lib/utils/UtilProxyCommon.java
  12. 2
    2
      src/main/java/pl/asie/charset/module/audio/storage/CharsetAudioStorage.java
  13. 2
    1
      src/main/java/pl/asie/charset/module/misc/pocketcraft/ContainerPocketTable.java
  14. 13
    0
      src/main/java/pl/asie/charset/module/storage/barrels/BarrelModel.java
  15. 13
    3
      src/main/java/pl/asie/charset/module/tweak/improvedCauldron/BlockCauldronCharset.java
  16. 10
    4
      src/main/java/pl/asie/charset/module/tweak/improvedCauldron/CharsetTweakImprovedCauldron.java
  17. 1
    0
      src/main/java/pl/asie/charset/module/tweak/improvedCauldron/api/ICauldronRecipe.java
  18. 13
    0
      src/main/java/pl/asie/charset/module/tweak/improvedCauldron/api/ICauldronRecipeViewable.java
  19. 13
    0
      src/main/java/pl/asie/charset/module/tweak/improvedCauldron/fluid/FluidDyedWater.java
  20. 62
    0
      src/main/java/pl/asie/charset/module/tweak/improvedCauldron/patches/RecipeHideItemDyeing.java
  21. 2
    2
      src/main/java/pl/asie/charset/module/tweak/improvedCauldron/recipe/RecipeDyeItem.java
  22. 95
    0
      src/main/java/pl/asie/charset/module/tweak/improvedCauldron/recipe/RecipeDyeItemPure.java
  23. 2
    0
      src/main/resources/assets/charset/lang/en_us.lang

+ 9
- 2
src/main/java/pl/asie/charset/lib/block/BlockBase.java View File

@@ -32,6 +32,7 @@ import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Enchantments;
@@ -54,6 +55,7 @@ import pl.asie.charset.lib.Properties;
import pl.asie.charset.lib.item.ISubItemProvider;
import pl.asie.charset.lib.render.ParticleDiggingCharset;
import pl.asie.charset.lib.render.model.IStateParticleBakedModel;
import pl.asie.charset.lib.utils.UtilProxyCommon;
import pl.asie.charset.lib.utils.Utils;

import javax.annotation.Nullable;
@@ -261,7 +263,7 @@ public abstract class BlockBase extends Block {
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
if (model instanceof IStateParticleBakedModel) {
state = getExtendedState(state.getActualState(world, pos), world, pos);
TextureAtlasSprite sprite = ((IStateParticleBakedModel) model).getParticleTexture(state);
TextureAtlasSprite sprite = ((IStateParticleBakedModel) model).getParticleTexture(state, null);
if (sprite != null) {
for (int j = 0; j < 4; ++j) {
for (int k = 0; k < 4; ++k) {
@@ -290,7 +292,7 @@ public abstract class BlockBase extends Block {
EnumFacing side = target.sideHit;

state = getExtendedState(state.getActualState(world, pos), world, pos);
TextureAtlasSprite sprite = ((IStateParticleBakedModel) model).getParticleTexture(state);
TextureAtlasSprite sprite = ((IStateParticleBakedModel) model).getParticleTexture(state, side);
if (sprite != null) {
int i = pos.getX();
int j = pos.getY();
@@ -349,6 +351,11 @@ public abstract class BlockBase extends Block {
return true;
}

@Override
public boolean addRunningEffects(IBlockState state, World world, BlockPos pos, Entity entity) {
return UtilProxyCommon.proxy.addRunningParticles(state, world, pos, entity);
}

@Override
public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) {
if (axis != null) {

+ 3
- 2
src/main/java/pl/asie/charset/lib/block/PacketCustomBlockDust.java View File

@@ -22,6 +22,7 @@ package pl.asie.charset.lib.block;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.INetHandler;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import pl.asie.charset.lib.network.Packet;
@@ -31,7 +32,7 @@ import pl.asie.charset.lib.utils.Utils;
import java.util.Random;

public class PacketCustomBlockDust extends Packet {
private static final Random rand = new Random();
public static final Random rand = new Random();
private World world;
private BlockPos pos;
@@ -72,7 +73,7 @@ public class PacketCustomBlockDust extends Packet {
public void apply(INetHandler handler) {
this.world = getWorld(handler, dim);
if (world != null) {
UtilProxyCommon.proxy.spawnBlockDustClient(world, pos, rand, posX, posY, posZ, numberOfParticles, particleSpeed);
UtilProxyCommon.proxy.spawnBlockDustClient(world, pos, rand, posX, posY, posZ, numberOfParticles, particleSpeed, EnumFacing.UP);
}
}


+ 6
- 4
src/main/java/pl/asie/charset/lib/notify/NotifyImplementation.java View File

@@ -39,6 +39,7 @@ import net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraftforge.fml.relauncher.Side;
import pl.asie.charset.lib.CharsetLib;
import pl.asie.charset.lib.loader.CharsetModule;
import pl.asie.charset.lib.utils.EntityUtils;

import java.util.ArrayList;
import java.util.Collection;
@@ -64,15 +65,16 @@ public class NotifyImplementation {
if (where == null) {
return;
}
if (player instanceof FakePlayer) {
return;
int baseRange = 32;
if (player != null && EntityUtils.isPlayerFake(player)) {
player = null;
}
if ((player != null && player.world.isRemote) || FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
if ((player != null && player.world.isRemote) || (world != null && world.isRemote)) {
proxy.addMessage(where, item, style, message);
} else {
TargetPoint target = null;
if (player == null) {
final int range = style.contains(NoticeStyle.DRAWFAR) ? 128 : 32;
final int range = style.contains(NoticeStyle.DRAWFAR) ? (baseRange * 4) : baseRange;
int x = 0, y = 0, z = 0;
boolean failed = false;
BlockPos pos = null;

+ 4
- 1
src/main/java/pl/asie/charset/lib/render/model/IStateParticleBakedModel.java View File

@@ -21,7 +21,10 @@ package pl.asie.charset.lib.render.model;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.EnumFacing;

import javax.annotation.Nullable;

public interface IStateParticleBakedModel {
TextureAtlasSprite getParticleTexture(IBlockState state);
TextureAtlasSprite getParticleTexture(IBlockState state, @Nullable EnumFacing facing);
}

+ 11
- 1
src/main/java/pl/asie/charset/lib/render/model/ModelFactory.java View File

@@ -42,6 +42,7 @@ import pl.asie.charset.ModCharset;
import pl.asie.charset.lib.utils.RenderUtils;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -120,6 +121,15 @@ public abstract class ModelFactory<T extends IRenderComparable<T>> extends BaseB
}
}

@Nullable
protected T get(IBlockState state) {
if (state instanceof IExtendedBlockState) {
return ((IExtendedBlockState) state).getValue(property);
} else {
return null;
}
}

private IBakedModel getModel(IBlockState state) {
return getModel(state, null);
}
@@ -150,7 +160,7 @@ public abstract class ModelFactory<T extends IRenderComparable<T>> extends BaseB
}

@Override
public TextureAtlasSprite getParticleTexture(IBlockState state) {
public TextureAtlasSprite getParticleTexture(IBlockState state, EnumFacing facing) {
IBakedModel model = getModel(state);
return model != null ? model.getParticleTexture() : getParticleTexture();
}

+ 6
- 14
src/main/java/pl/asie/charset/lib/render/sprite/SpritesheetFactory.java View File

@@ -19,6 +19,7 @@

package pl.asie.charset.lib.render.sprite;

import com.google.common.base.Suppliers;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
@@ -29,15 +30,12 @@ import pl.asie.charset.lib.utils.RenderUtils;

import java.awt.image.BufferedImage;
import java.util.function.Function;
import java.util.function.Supplier;

public class SpritesheetFactory {
private final ResourceLocation location;
private final int width, height;

public final class SpritesheetFactory {
protected static class SliceSprite extends TextureAtlasSpriteCustom {
private final ResourceLocation location;
private final int x, y, width, height;
private BufferedImage sheet;

protected SliceSprite(ResourceLocation loc, ResourceLocation location, int i, int width, int height) {
super(loc.toString());
@@ -55,6 +53,7 @@ public class SpritesheetFactory {

@Override
public boolean load(IResourceManager manager, ResourceLocation loc, Function<ResourceLocation, TextureAtlasSprite> getter) {
BufferedImage sheet = null;
if (sheet == null) {
sheet = RenderUtils.getTextureImage(location);
if (sheet == null) {
@@ -74,18 +73,11 @@ public class SpritesheetFactory {
}
}

private SpritesheetFactory(ResourceLocation location, int width, int height) {
this.location = location;
this.width = width;
this.height = height;
}
private SpritesheetFactory() {

public static TextureAtlasSprite[] register(TextureMap map, ResourceLocation location, int width, int height) {
SpritesheetFactory factory = new SpritesheetFactory(location, width, height);
return factory.register(map);
}

public TextureAtlasSprite[] register(TextureMap map) {
public static TextureAtlasSprite[] register(TextureMap map, ResourceLocation location, int width, int height) {
TextureAtlasSprite[] sprites = new TextureAtlasSprite[width * height];
for (int i = 0; i < sprites.length; i++) {
String s = String.format(location.toString() + "#%d", i);

+ 62
- 22
src/main/java/pl/asie/charset/lib/utils/FluidUtils.java View File

@@ -39,6 +39,7 @@ import pl.asie.charset.lib.capability.CapabilityHelper;
import pl.asie.charset.module.storage.tanks.TileTank;

import javax.annotation.Nullable;
import java.util.Optional;

public final class FluidUtils {
public static String getCorrectUnlocalizedName(FluidStack stack) {
@@ -78,8 +79,7 @@ public final class FluidUtils {
}
}

public static boolean handleTank(IFluidHandler tank, FluidStack fluidContained, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand) {
ItemStack stack = playerIn.getHeldItem(hand);
public static Optional<ItemStack> handleTank(IFluidHandler tank, FluidStack fluidContained, World worldIn, BlockPos pos, ItemStack stack, boolean isCreative, boolean drainTank, boolean fillTank) {
IFluidHandlerItem handler = CapabilityHelper.get(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, stack, null);
if (handler != null) {
if (!worldIn.isRemote) {
@@ -95,41 +95,81 @@ public final class FluidUtils {
}

if (fluidExtracted == null) {
// tank -> holder
fluidExtracted = drain(tank, Fluid.BUCKET_VOLUME, false, false);
if (fluidExtracted != null) {
int amount = handler.fill(fluidExtracted, false);
if (amount > 0) {
fluidExtracted.amount = amount;
fluidExtracted = drain(tank, fluidExtracted, true, false);
if (fluidExtracted != null) {
handler.fill(fluidExtracted, true);
changed = true;
if (drainTank) {
// tank -> holder
fluidExtracted = drain(tank, Fluid.BUCKET_VOLUME, false, false);
if (fluidExtracted != null) {
int amount = handler.fill(fluidExtracted, false);
if (amount > 0) {
fluidExtracted.amount = amount;
fluidExtracted = drain(tank, fluidExtracted, true, false);
if (fluidExtracted != null) {
handler.fill(fluidExtracted, true);
changed = true;
}
}
}
}
} else {
// holder -> tank
int amount = tank.fill(fluidExtracted, false);
if (amount > 0) {
fluidExtracted.amount = amount;
fluidExtracted = handler.drain(fluidExtracted, !playerIn.isCreative());
if (fluidExtracted != null) {
tank.fill(fluidExtracted, true);
changed = true;
if (fillTank) {
int amount = tank.fill(fluidExtracted, false);
if (amount > 0) {
fluidExtracted.amount = amount;
fluidExtracted = handler.drain(fluidExtracted, !isCreative);
if (fluidExtracted != null) {
tank.fill(fluidExtracted, true);
changed = true;
}
}
}
}

if (changed) {
playerIn.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, handler.getContainer());
return Optional.of(handler.getContainer());
}
}

return true;
return Optional.of(stack);
}

return false;
return Optional.empty();

}

public static boolean handleTank(IFluidHandler tank, FluidStack fluidContained, World worldIn, BlockPos pos, EntityPlayer playerIn, EnumHand hand) {
ItemStack stack = playerIn.getHeldItem(hand);
if (stack.isEmpty()) {
return false;
} else if (stack.getCount() == 1) {
Optional<ItemStack> result = handleTank(tank, fluidContained, worldIn, pos, stack, playerIn.isCreative(), true, true);
if (result.isPresent()) {
ItemStack resultStack = result.get();
if (resultStack != stack) {
playerIn.setHeldItem(hand, resultStack);
}

return true;
} else {
return false;
}
} else {
ItemStack stackOne = stack.splitStack(1);

Optional<ItemStack> result = handleTank(tank, fluidContained, worldIn, pos, stackOne, playerIn.isCreative(), true, true);
if (result.isPresent()) {
ItemStack resultStack = result.get();
if (resultStack != stackOne) {
playerIn.inventory.addItemStackToInventory(resultStack);
} else {
stackOne.grow(1);
}

return true;
} else {
return false;
}
}
}

public static boolean matches(IFluidHandler handler, FluidStack stack) {

+ 4
- 0
src/main/java/pl/asie/charset/lib/utils/ItemUtils.java View File

@@ -40,8 +40,12 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.commons.lang3.tuple.Pair;
import pl.asie.charset.lib.CharsetLib;

import javax.annotation.Nullable;
import java.util.Optional;

public final class ItemUtils {
private ItemUtils() {


+ 1
- 0
src/main/java/pl/asie/charset/lib/utils/RecipeUtils.java View File

@@ -26,6 +26,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.world.World;
import net.minecraftforge.common.crafting.IShapedRecipe;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.oredict.ShapedOreRecipe;


+ 23
- 2
src/main/java/pl/asie/charset/lib/utils/UtilProxyClient.java View File

@@ -31,12 +31,14 @@ import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.network.INetHandler;
import net.minecraft.network.login.INetHandlerLoginClient;
import net.minecraft.network.play.INetHandlerPlayClient;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
@@ -48,8 +50,10 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.registries.IForgeRegistryEntry;
import pl.asie.charset.ModCharset;
import pl.asie.charset.lib.block.BlockBase;
import pl.asie.charset.lib.block.PacketCustomBlockDust;
import pl.asie.charset.lib.item.FontRendererFancy;
import pl.asie.charset.lib.render.ParticleBlockDustCharset;
import pl.asie.charset.lib.render.ParticleDiggingCharset;
import pl.asie.charset.lib.render.model.IStateParticleBakedModel;
import pl.asie.charset.lib.resources.CharsetFakeResourcePack;

@@ -60,6 +64,23 @@ import java.util.Random;
public class UtilProxyClient extends UtilProxyCommon {
public static FontRenderer FONT_RENDERER_FANCY;

@Override
public boolean addRunningParticles(IBlockState state, World world, BlockPos pos, Entity entity) {
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
if (model instanceof IStateParticleBakedModel) {
state = state.getBlock().getExtendedState(state.getActualState(world, pos), world, pos);
TextureAtlasSprite sprite = ((IStateParticleBakedModel) model).getParticleTexture(state, EnumFacing.UP);

Particle particle = new ParticleDiggingCharset(world, entity.posX + ((double)PacketCustomBlockDust.rand.nextFloat() - 0.5D) * (double)entity.width, entity.getEntityBoundingBox().minY + 0.1D, entity.posZ + ((double) PacketCustomBlockDust.rand.nextFloat() - 0.5D) * (double)entity.width, -entity.motionX * 4.0D, 1.5D, -entity.motionZ * 4.0D,
state, pos, sprite, ((BlockBase) state.getBlock()).getParticleTintIndex());
Minecraft.getMinecraft().effectRenderer.addEffect(particle);

return true;
} else {
return false;
}
}

@Override
public void init() {
super.init();
@@ -178,7 +199,7 @@ public class UtilProxyClient extends UtilProxyCommon {
}

@Override
public void spawnBlockDustClient(World world, BlockPos pos, Random rand, float posX, float posY, float posZ, int numberOfParticles, float particleSpeed) {
public void spawnBlockDustClient(World world, BlockPos pos, Random rand, float posX, float posY, float posZ, int numberOfParticles, float particleSpeed, EnumFacing facing) {
TextureAtlasSprite sprite;
int tintIndex = -1;

@@ -190,7 +211,7 @@ public class UtilProxyClient extends UtilProxyCommon {
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
if (model instanceof IStateParticleBakedModel) {
state = state.getBlock().getExtendedState(state.getActualState(world, pos), world, pos);
sprite = ((IStateParticleBakedModel) model).getParticleTexture(state);
sprite = ((IStateParticleBakedModel) model).getParticleTexture(state, facing);
} else {
sprite = model.getParticleTexture();
}

+ 7
- 1
src/main/java/pl/asie/charset/lib/utils/UtilProxyCommon.java View File

@@ -27,6 +27,7 @@ import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -35,6 +36,7 @@ import net.minecraft.item.Item;
import net.minecraft.network.INetHandler;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IThreadListener;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -77,6 +79,10 @@ public class UtilProxyCommon implements IThreadListener {
return "en_us";
}

public boolean addRunningParticles(IBlockState state, World world, BlockPos pos, Entity entity) {
return true;
}

public void registerItemModel(Item item, int meta, String name) {

}
@@ -110,7 +116,7 @@ public class UtilProxyCommon implements IThreadListener {

}

public void spawnBlockDustClient(World world, BlockPos pos, Random rand, float posX, float posY, float posZ, int numberOfParticles, float particleSpeed) {
public void spawnBlockDustClient(World world, BlockPos pos, Random rand, float posX, float posY, float posZ, int numberOfParticles, float particleSpeed, EnumFacing facing) {

}


+ 2
- 2
src/main/java/pl/asie/charset/module/audio/storage/CharsetAudioStorage.java View File

@@ -57,8 +57,8 @@ import java.util.List;

@CharsetModule(
name = "audio.storage",
description = "Audio storage, recording and playback - Quartz Discs - still highly experimental",
profile = ModuleProfile.EXPERIMENTAL
description = "Audio storage, recording and playback - Quartz Discs",
profile = ModuleProfile.TESTING
)
public class CharsetAudioStorage {
@CapabilityInject(IDataStorage.class)

+ 2
- 1
src/main/java/pl/asie/charset/module/misc/pocketcraft/ContainerPocketTable.java View File

@@ -30,6 +30,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import pl.asie.charset.lib.ui.ContainerBase;
import pl.asie.charset.lib.ui.SlotBlocked;
import pl.asie.charset.lib.utils.ItemUtils;
import pl.asie.charset.lib.utils.RecipeUtils;

import java.util.ArrayList;
import java.util.List;
@@ -99,7 +100,7 @@ public class ContainerPocketTable extends ContainerBase {
}
movePlayerToMatrix();
ItemStack result = ItemStack.EMPTY;
IRecipe match = CraftingManager.findMatchingRecipe(craftMatrix, player.getEntityWorld());
IRecipe match = RecipeUtils.findMatchingRecipe(craftMatrix, player.getEntityWorld());
if (match != null) {
result = match.getCraftingResult(craftMatrix);
}

+ 13
- 0
src/main/java/pl/asie/charset/module/storage/barrels/BarrelModel.java View File

@@ -20,12 +20,14 @@
package pl.asie.charset.module.storage.barrels;

import com.google.common.collect.ImmutableMap;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoader;
@@ -36,6 +38,7 @@ import pl.asie.charset.lib.render.model.ModelFactory;
import pl.asie.charset.lib.render.model.WrappedBakedModel;
import pl.asie.charset.lib.utils.RenderUtils;

import javax.annotation.Nullable;
import java.lang.reflect.Field;

public class BarrelModel extends ModelFactory<BarrelCacheInfo> {
@@ -73,6 +76,16 @@ public class BarrelModel extends ModelFactory<BarrelCacheInfo> {
}
}

@Override
public TextureAtlasSprite getParticleTexture(IBlockState state, @Nullable EnumFacing facing) {
BarrelCacheInfo info = get(state);
if (info != null) {
return (facing != null && info.orientation.top.getAxis() == facing.getAxis()) ? info.plank : info.log;
} else {
return super.getParticleTexture();
}
}

@Override
public IBakedModel bake(BarrelCacheInfo info, boolean isItem, BlockRenderLayer layer) {
TextureAtlasSprite log = info.log;

+ 13
- 3
src/main/java/pl/asie/charset/module/tweak/improvedCauldron/BlockCauldronCharset.java View File

@@ -102,15 +102,25 @@ public class BlockCauldronCharset extends BlockCauldron implements ITileEntityPr
if (entityIn instanceof EntityItem) {
EntityItem entityItem = (EntityItem) entityIn;
ItemStack heldItem = entityItem.getItem();

if (!heldItem.isEmpty()) {
ItemStack heldItemOne = heldItem.copy();
heldItemOne.setCount(1);
Optional<CauldronContents> contentsNew = CharsetTweakImprovedCauldron.craft(tile, new CauldronContents(stack, heldItemOne));
Optional<CauldronContents> contentsNew = Optional.empty();

Optional<ItemStack> fluidResult = FluidUtils.handleTank((IFluidHandler) tile, stack, worldIn, pos, heldItemOne, false, true, false);
if (fluidResult.isPresent()) {
contentsNew = Optional.of(new CauldronContents(((TileCauldronCharset) tile).getContents(), fluidResult.get()));
}

if (!contentsNew.isPresent()) {
contentsNew = CharsetTweakImprovedCauldron.craft(tile, new CauldronContents(stack, heldItemOne));
}

if (contentsNew.isPresent()) {
CauldronContents cc = contentsNew.get();
if (!cc.hasResponse()) {
if (cc.hasResponse()) {
new Notice(tile, cc.getResponse()).sendToAll();
} else {
if (cc.getHeldItem().isEmpty()) {
heldItem.shrink(1);
} else if (cc.getHeldItem().getCount() == 1 && ItemUtils.canMerge(cc.getHeldItem(), heldItem)) {

+ 10
- 4
src/main/java/pl/asie/charset/module/tweak/improvedCauldron/CharsetTweakImprovedCauldron.java View File

@@ -22,6 +22,7 @@ package pl.asie.charset.module.tweak.improvedCauldron;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.common.MinecraftForge;
@@ -33,6 +34,7 @@ import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@@ -43,10 +45,8 @@ import pl.asie.charset.module.tweak.improvedCauldron.api.CauldronContents;
import pl.asie.charset.module.tweak.improvedCauldron.api.ICauldronRecipe;
import pl.asie.charset.module.tweak.improvedCauldron.fluid.FluidDyedWater;
import pl.asie.charset.module.tweak.improvedCauldron.fluid.FluidTextureGenerator;
import pl.asie.charset.module.tweak.improvedCauldron.recipe.RecipeBucketCraft;
import pl.asie.charset.module.tweak.improvedCauldron.recipe.RecipeDyeItem;
import pl.asie.charset.module.tweak.improvedCauldron.recipe.RecipeDyeWater;
import pl.asie.charset.module.tweak.improvedCauldron.recipe.RecipeWashDyedWater;
import pl.asie.charset.module.tweak.improvedCauldron.patches.RecipeHideItemDyeing;
import pl.asie.charset.module.tweak.improvedCauldron.recipe.*;

import java.util.ArrayList;
import java.util.List;
@@ -90,6 +90,7 @@ public class CharsetTweakImprovedCauldron {
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
recipeList.add(new RecipeDyeWater());
recipeList.add(new RecipeDyeItemPure()); // has to go before RecipeDyeItem to emit error on impure dye
recipeList.add(new RecipeDyeItem());
recipeList.add(new RecipeWashDyedWater());
recipeList.add(new RecipeBucketCraft());
@@ -121,6 +122,11 @@ public class CharsetTweakImprovedCauldron {
event.getRegistry().register(blockCauldron.setRegistryName("minecraft:cauldron"));
}

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void disableRecipes(RegistryEvent.Register<IRecipe> event) {
event.getRegistry().register(new RecipeHideItemDyeing("charset:recipe_hide_item_dye").setRegistryName("charset:recipe_hide_item_dye"));
}

@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
if (!event.getWorld().isRemote) {

+ 1
- 0
src/main/java/pl/asie/charset/module/tweak/improvedCauldron/api/ICauldronRecipe.java View File

@@ -22,6 +22,7 @@ package pl.asie.charset.module.tweak.improvedCauldron.api;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.util.Collection;
import java.util.Optional;

@FunctionalInterface

+ 13
- 0
src/main/java/pl/asie/charset/module/tweak/improvedCauldron/api/ICauldronRecipeViewable.java View File

@@ -0,0 +1,13 @@
package pl.asie.charset.module.tweak.improvedCauldron.api;

import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;

import java.util.Collection;

public interface ICauldronRecipeViewable extends ICauldronRecipe {
Collection<CauldronContents> getRecipesForInputItem(ItemStack stack);
Collection<CauldronContents> getRecipesForInputFluid(FluidStack stack);
Collection<CauldronContents> getRecipesForOutputItem(ItemStack stack);
Collection<CauldronContents> getRecipesForOutputFluid(FluidStack stack);
}

+ 13
- 0
src/main/java/pl/asie/charset/module/tweak/improvedCauldron/fluid/FluidDyedWater.java View File

@@ -45,6 +45,19 @@ public class FluidDyedWater extends Fluid {
super(fluidName, TEXTURE_STILL, TEXTURE_FLOW);
}

@Override
public String getUnlocalizedName(FluidStack stack) {
NBTTagCompound tag = stack.tag;
if (tag != null && tag.hasKey("dyes", Constants.NBT.TAG_LIST)) {
NBTTagList dyes = ((NBTTagList) stack.tag.getTag("dyes"));
if (dyes.tagCount() == 1) {
return "fluid.charset.dyed_water.pure";
}
}

return "fluid.charset.dyed_water";
}

@Nullable
public FluidStack appendDye(FluidStack stack, EnumDyeColor color) {
FluidStack newStack;

+ 62
- 0
src/main/java/pl/asie/charset/module/tweak/improvedCauldron/patches/RecipeHideItemDyeing.java View File

@@ -0,0 +1,62 @@
package pl.asie.charset.module.tweak.improvedCauldron.patches;

import com.google.gson.JsonObject;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.crafting.JsonContext;
import net.minecraftforge.registries.IForgeRegistryEntry;
import pl.asie.charset.lib.recipe.RecipeBase;
import pl.asie.charset.lib.utils.ColorUtils;
import pl.asie.charset.lib.utils.ItemUtils;

import javax.annotation.Nullable;

public class RecipeHideItemDyeing extends RecipeBase {
public RecipeHideItemDyeing(String group) {
super(group, true);
}

@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
int dyeCount = 0;
int nonDyeItemCount = 0;
ItemStack nonDyeItem = ItemStack.EMPTY;

for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (!stack.isEmpty()) {
if (ColorUtils.getDyeColor(stack) != null) {
dyeCount++;
} else if (nonDyeItem.isEmpty()) {
nonDyeItem = stack;
nonDyeItemCount = 1;
} else if (ItemUtils.canMerge(nonDyeItem, stack)) {
nonDyeItemCount++;
} else {
return false;
}
}
}

return (nonDyeItemCount == 1 && (dyeCount >= 1 && dyeCount <= 8))
|| (nonDyeItemCount == 8 && dyeCount == 1);
}

@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
return ItemStack.EMPTY;
}

@Override
public boolean canFit(int width, int height) {
return (width * height) >= 2;
}

@Override
public ItemStack getRecipeOutput() {
return ItemStack.EMPTY;
}
}

+ 2
- 2
src/main/java/pl/asie/charset/module/tweak/improvedCauldron/recipe/RecipeDyeItem.java View File

@@ -48,7 +48,7 @@ public class RecipeDyeItem implements ICauldronRecipe {

if (stack.getFluid() == CharsetTweakImprovedCauldron.dyedWater
&& stack.tag != null
&& stack.amount >= 250
&& stack.amount >= 125
&& stack.tag.hasKey("dyes", Constants.NBT.TAG_LIST)) {

NBTTagList dyes = (NBTTagList) stack.tag.getTag("dyes");
@@ -66,7 +66,7 @@ public class RecipeDyeItem implements ICauldronRecipe {
ItemStack result = RecipeUtils.getCraftingResult(world, 3, 3, stacks);
if (!result.isEmpty() && !ItemUtils.canMerge(stacks[0], result)) {
return Optional.of(new CauldronContents(
new FluidStack(stack, stack.amount - 250),
new FluidStack(stack, stack.amount - 125),
result
));
}

+ 95
- 0
src/main/java/pl/asie/charset/module/tweak/improvedCauldron/recipe/RecipeDyeItemPure.java View File

@@ -0,0 +1,95 @@
/*
* Copyright (c) 2015, 2016, 2017, 2018 Adrian Siekierka
*
* This file is part of Charset.
*
* Charset is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Charset is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Charset. If not, see <http://www.gnu.org/licenses/>.
*/

package pl.asie.charset.module.tweak.improvedCauldron.recipe;

import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTPrimitive;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.FluidStack;
import pl.asie.charset.lib.utils.ItemUtils;
import pl.asie.charset.lib.utils.RecipeUtils;
import pl.asie.charset.module.tweak.improvedCauldron.CharsetTweakImprovedCauldron;
import pl.asie.charset.module.tweak.improvedCauldron.api.CauldronContents;
import pl.asie.charset.module.tweak.improvedCauldron.api.ICauldronRecipe;

import java.util.Optional;

public class RecipeDyeItemPure implements ICauldronRecipe {
@Override
public Optional<CauldronContents> apply(World world, BlockPos pos, CauldronContents contents) {
if (!contents.hasFluidStack() || !contents.hasHeldItem()) {
return Optional.empty();
}

FluidStack stack = contents.getFluidStack();
ItemStack heldItem = contents.getHeldItem();

if (stack.getFluid() == CharsetTweakImprovedCauldron.dyedWater
&& stack.tag != null
&& stack.amount >= 125
&& stack.tag.hasKey("dyes", Constants.NBT.TAG_LIST)) {

NBTTagList dyes = (NBTTagList) stack.tag.getTag("dyes");
boolean isImpure = dyes.tagCount() > 1;

ItemStack[] stacks = new ItemStack[9];
stacks[0] = heldItem.copy();
stacks[0].setCount(1);
for (int i = 1; i <= 8; i++) {
if (i == 4) continue;
stacks[i] = stacks[0];
}
stacks[4] = new ItemStack(Items.DYE, 1, 15 - ((NBTPrimitive) dyes.get(0)).getByte());

ItemStack result = RecipeUtils.getCraftingResult(world, 3, 3, stacks);
int expectedCount = 8;

if (result.isEmpty()) {
stacks = new ItemStack[2];
stacks[0] = heldItem.copy();
stacks[0].setCount(1);
stacks[1] = new ItemStack(Items.DYE, 1, 15 - ((NBTPrimitive) dyes.get(0)).getByte());

result = RecipeUtils.getCraftingResult(world, 2, 1, stacks);
expectedCount = 1;
}

if (!result.isEmpty() && result.getCount() == expectedCount && !ItemUtils.canMerge(stacks[0], result)) {
if (isImpure) {
return Optional.of(new CauldronContents(new TextComponentTranslation("notice.charset.cauldron.dye_impure")));
} else {
ItemStack result1 = result.copy();
result1.setCount(1);
return Optional.of(new CauldronContents(
new FluidStack(stack, stack.amount - 125),
result1
));
}
}
}

return Optional.empty();
}
}

+ 2
- 0
src/main/resources/assets/charset/lang/en_us.lang View File

@@ -1,5 +1,7 @@
chat.charset.shout=%1$s %2$s
fluid.charset.dyed_water.name=Dyed Water
fluid.charset.dyed_water.pure.name=Pure Dyed Water
notice.charset.cauldron.dye_impure=Must use pure dyed water!
notice.charset.cauldron.no_dye=Cannot mix more dye!
notice.charset.cauldron.empty=Empty
notice.charset.cauldron.fluid=%1$s mB of %2$s

Loading…
Cancel
Save