Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

ChonkoTheGreat

Members
  • Posts

    4
  • Joined

  • Last visited

ChonkoTheGreat's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. In the Main Class i have: private void setup(final FMLCommonSetupEvent event) { VillagerUtil.fixPOITypeBlockStates(PointOfInterestTypes.HATMAKER); Then I have VillagerUtil: public class VillagerUtil { private static Method blockStatesInjector; static { VillagerUtil.blockStatesInjector = ObfuscationReflectionHelper.findMethod(PointOfInterestType.class, "func_221052_a", PointOfInterestType.class); } public static Set<BlockState> getAllStates(Block block) { return ImmutableSet.copyOf(block.getStateContainer().getValidStates()); } public static void fixPOITypeBlockStates(PointOfInterestType poiType) { try { VillagerUtil.blockStatesInjector.invoke(null, poiType); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } } public static PointOfInterestType pointOfInterestType(String p1, Set<BlockState> p2, int p3, int p4) { try { // Constructor<PointOfInterestType> c = (Constructor<PointOfInterestType>)PointOfInterestType.class.getDeclaredConstructors()[1]; Constructor<PointOfInterestType> c = PointOfInterestType.class.getDeclaredConstructor(String.class, Set.class, Integer.TYPE, Integer.TYPE); c.setAccessible(true); return c.newInstance(p1, p2, p3, p4); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return null; } public static VillagerProfession villagerProfession(String p1, PointOfInterestType p2, ImmutableSet<Item> p3, ImmutableSet<Block> p4, @Nullable SoundEvent p5) { try { Constructor<VillagerProfession> c = VillagerProfession.class.getDeclaredConstructor(String.class, PointOfInterestType.class, ImmutableSet.class, ImmutableSet.class, SoundEvent.class); c.setAccessible(true); return c.newInstance(p1, p2, p3, p4, p5); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return null; } } ProfessionInit: @EventBusSubscriber(modid = MikesFancyContent.MOD_ID, bus = Bus.MOD) @ObjectHolder(MikesFancyContent.MOD_ID) public class ProfessionInit { public static final VillagerProfession HATMAKER = null; @SubscribeEvent public static void registerVillagerProfessions(Register<VillagerProfession> event) { IForgeRegistry<VillagerProfession> registry = event.getRegistry(); registry.register(VillagerUtil.villagerProfession("hatmaker", PointOfInterestTypes.HATMAKER, ImmutableSet.of(), ImmutableSet.of(), null).setRegistryName(MikesFancyContent.MOD_ID, "hatmaker")); } } TradeRegistration: @Mod.EventBusSubscriber(modid = MikesFancyContent.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class TradeRegistration { @SubscribeEvent public static void registerTrades(VillagerTradesEvent event){ if (event.getType() == ProfessionInit.HATMAKER) { event.getTrades().get(1).add((new TradeBuilder(64, 25, 0.05F).setPrice(Items.EMERALD, 1,1).setForSale(Items.STRING, 5, 1).build())); event.getTrades().get(1).add((new TradeBuilder(64, 25, 0.05F).setPrice(Items.EMERALD, 1,1).setForSale(Items.FEATHER, 5, 1).build())); event.getTrades().get(2).add((new TradeBuilder(64, 25, 0.2F).setPrice(Items.EMERALD, 1,1).setForSale(Items.WHITE_WOOL, 5, 2).build())); event.getTrades().get(2).add((new TradeBuilder(64, 25, 0.2F).setPrice(Items.EMERALD, 1,1).setForSale(Items.BLACK_WOOL, 1, 2).build())); //gonna change the rest soon -mike event.getTrades().get(3).add((new TradeBuilder(64, 25, 0.05F).setPrice(Items.EMERALD, 1,1).setForSale(Items.DIRT, 1, 2).build())); event.getTrades().get(3).add((new TradeBuilder(64, 25, 0.05F).setPrice(Items.EMERALD, 1,1).setForSale(Items.DIRT, 1, 2).build())); event.getTrades().get(4).add((new TradeBuilder(64, 25, 0.2F).setPrice(Items.EMERALD, 1,1).setForSale(Items.DIRT, 1, 2).build())); event.getTrades().get(4).add((new TradeBuilder(64, 25, 0.2F).setPrice(Items.EMERALD, 1,1).setForSale(Items.DIRT, 1, 2).build())); event.getTrades().get(5).add((new TradeBuilder(64, 25, 0.2F).setPrice(Items.EMERALD, 1,1).setForSale(Items.DIRT, 1, 2).build())); event.getTrades().get(5).add((new TradeBuilder(64, 50, 0.05F).setPrice(Items.EMERALD, 3,6).setForSale(Items.DIRT, 1, 1).build())); } TradeBuilder: public class TradeBuilder { private static final ArrayList<ArrayList<TradeBuilder>> TRADES_LIST = new ArrayList<>(); static { for(int i = 0; i <= 6; ++i) { TradeBuilder.TRADES_LIST.add(new ArrayList<TradeBuilder>()); } } private static ArrayList<TradeBuilder> getList(int i) { return TradeBuilder.TRADES_LIST.get(i); } private static void register(int i, TradeBuilder tradeBuilder) { TradeBuilder.getList(i).add(tradeBuilder); } public static void forEachLevel(BiConsumer<Integer, TradeBuilder> consumer) { ArrayList<TradeBuilder> list; for(int i = 1; i <= 5; ++i) { list = TradeBuilder.TRADES_LIST.get(i - 1); for(TradeBuilder tradeBuilder : list) { consumer.accept(i, tradeBuilder); } } } public static void forEachLevel(Consumer<TradeBuilder> consumer) { TradeBuilder.forEachLevel((level, tradeBuilder) -> consumer.accept(tradeBuilder)); } public static void forEachWanderer(Consumer<TradeBuilder> consumer) { ArrayList<TradeBuilder> list = TradeBuilder.TRADES_LIST.get(5); for(TradeBuilder tradeBuilder : list) { consumer.accept(tradeBuilder); } } public static void forEachWandererRare(Consumer<TradeBuilder> consumer) { ArrayList<TradeBuilder> list = TradeBuilder.TRADES_LIST.get(6); for(TradeBuilder tradeBuilder : list) { consumer.accept(tradeBuilder); } } protected Function<Random, ItemStack> price; protected Function<Random, ItemStack> price2; protected Function<Random, ItemStack> forSale; protected final int maxTrades; protected final int xp; protected final float priceMult; protected boolean rare; public TradeBuilder(int maxTrades, int xp, float priceMult) { this.price = null; this.price2 = (random) -> ItemStack.EMPTY; this.forSale = null; this.maxTrades = maxTrades; this.xp = xp; this.priceMult = priceMult; this.rare = false; } public TradeBuilder setPrice(Function<Random, ItemStack> price) { this.price = price; return this; } public TradeBuilder setPrice(Item item, int min, int max) { return this.setPrice(TradeBuilder.createFunction(item, min, max)); } public TradeBuilder setPrice2(Function<Random, ItemStack> price2) { this.price2 = price2; return this; } public TradeBuilder setPrice2(Item item, int min, int max) { return this.setPrice2(TradeBuilder.createFunction(item, min, max)); } public TradeBuilder setForSale(Function<Random, ItemStack> forSale) { this.forSale = forSale; return this; } public TradeBuilder setForSale(Item item, int min, int max) { return this.setForSale(TradeBuilder.createFunction(item, min, max)); } public TradeBuilder setForSale(MusicDiscItem item, int min, int max) { return this.setForSale(TradeBuilder.createFunction(item, min, max)); } public TradeBuilder setForSale(RegistryObject<MusicDiscItem> item, int min, int max) { return this.setForSale(TradeBuilder.createFunction(item, min, max)); } public TradeBuilder setEmeraldPrice(int emeralds) { return this.setPrice((random) -> new ItemStack(Items.EMERALD, emeralds)); } public TradeBuilder setEmeraldPriceFor(int emeralds, Item item, int amt) { this.setEmeraldPrice(emeralds); return this.setForSale((random) -> new ItemStack(item, amt)); } public TradeBuilder setEmeraldPriceFor(int emeralds, Item item) { return this.setEmeraldPriceFor(emeralds, item, 1); } public TradeBuilder setEmeraldPrice(int min, int max) { return this.setPrice(Items.EMERALD, min, max); } public TradeBuilder setEmeraldPriceFor(int min, int max, Item item, int amt) { this.setEmeraldPrice(min, max); return this.setForSale((random) -> new ItemStack(item, amt)); } public TradeBuilder setEmeraldPriceFor(int min, int max, Item item) { return this.setEmeraldPriceFor(min, max, item, 1); } public TradeBuilder setRare() { this.rare = true; return this; } public boolean canBuild() { return this.price != null && this.forSale != null; } public ITrade build() { return (entity, random) -> !this.canBuild() ? null : new MerchantOffer(this.price.apply(random), this.price2.apply(random), this.forSale.apply(random), this.maxTrades, this.xp, this.priceMult); } public static Function<Random, ItemStack> createFunction(Item item, int min, int max) { return (random) -> new ItemStack(item, random.nextInt(max) + min); } protected TradeBuilder register(int index) { TradeBuilder.register(index, this); return this; } /** * @param level 1-5 */ public TradeBuilder registerLevel(int level) { return this.register(level - 1); } public TradeBuilder registerWanderer(boolean rare) { return this.register(rare ? 6 : 5); } } and lastly, PointOfInterestTypes: @EventBusSubscriber(modid = MikesFancyContent.MOD_ID, bus = Bus.MOD) @ObjectHolder(MikesFancyContent.MOD_ID) public class PointOfInterestTypes { public static final PointOfInterestType HATMAKER = null; @SubscribeEvent public static void registerPointOfInterestTypes(Register<PointOfInterestType> event) { IForgeRegistry<PointOfInterestType> registry = event.getRegistry(); registry.register(VillagerUtil.pointOfInterestType("hatmaker", VillagerUtil.getAllStates(BlockInit.HATMAKER_POI.get()), 1, 1).setRegistryName(MikesFancyContent.MOD_ID, "hatmaker")); } }
  2. Sorry if I explain this badly: Basically, I have made a Villager texture and I want to not have the texture for the Villager biome variant appear on them. This is how I want the Villager to look in-game This is how he looks in-game. As you can see, the clothes (In this example the regular Plains Villager) still appear. Is there any way to change this? Thanks in advance.
  3. I added a new type of wood in my mod, so how exactly do I make them rotatable? I have already created changed the blockstate .json to how it is used in Minecraft, what else do I have to do to make them work?
  4. I am currently making a mod for me and my friends. I wanted to make an ore generate in the End but I can only select BASE_STONE_OVERWORLD and BASE_STONE_NETHER. How do I get something like BASE_STONE_END?
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.