
Zeurkous
Members-
Posts
25 -
Joined
-
Last visited
Everything posted by Zeurkous
-
This totally works, thanks alot. You're a lifesaver. Generics is something I've been struggling with. Thanks again
-
I'm sorry man, I'm lost over here. Care to help me out?
-
This is where my Java knowledge lets me down. I'll try to find a solution to that. In the mean time, I thank you for the help so far.
-
Right. I'm getting really confused when I'm working with DataTypes I don't understand. So for(Comparable<?> value : prop.getAllowedValues()){ prop.getName(value); } gives me this error on #getName(value): "The method getName(capture#3-of ?) in the type IProperty<capture#3-of ?> is not applicable for the arguments (Comparable<capture#4-of ?>)"
-
But that gives me thing like 'variant' , 'color', etc.. That part is done. for(IProperty<?> prop : block.getDefaultState().getPropertyNames()){ String propname = prop.getName(); if(propname.equals("variant")){ No?
-
Yes, but this gives me an error for(IProperty value : prop.getAllowedValues()){} Am I missing something? I feel like I'm doing something very wrong here.
-
Okay you said "at hand", I read "in hand". My bad. Fixed that. On the other 2 problems however you lost me sorry. I'm iterating over the possible values for(Comparable<?> value : prop.getAllowedValues()){} but then value doesn't have a #getName And if I try for(IProperty value : prop.getAllowedValues()){} It tells me to change the type of value to Comparable<T> (Eclipse does that)
-
1. Cause the sign is not in my hand, It's a sign that is placed somewhere that the player then can rightclick. So is there a better way? 2. Alright thanks i'll remove that. 3. Well purely for testing I hardcoded variant. I'm aware that other blocks have other property's (atleast I just found out) 4. if(values instanceof BlockPlanks.EnumType){ } So then how would I compare this to the variant input? Okay so I guess that i'll need a switch to makes sure that the EnumType matches the item? 5. Well but how do I set the block to be the block of that variant (in this case) I'm sorry if I'm being a noob here Don't have alot modding experience
-
Following what diesieben07 told me I came to this @SubscribeEvent public void onRightClickBlock(RightClickBlock e) { World world = e.getWorld(); if (!world.isRemote) { String name = world.getBlockState(e.getPos()).getBlock().getLocalizedName(); if (name.equals("Sign")) { TileEntitySign sign = (TileEntitySign) world.getTileEntity(e.getPos()); String itemString = sign.signText[0].getUnformattedComponentText().toLowerCase(); String variant = sign.signText[1].getUnformattedComponentText().toLowerCase(); //Important stuff Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("minecraft:" + itemString)); for(IProperty<?> prop : block.getDefaultState().getPropertyNames()){ String propname = prop.getName(); if(propname.equals("variant")){ for(Comparable<?> values : prop.getAllowedValues()){ if(values.equals(variant)){ // So what now ItemStack stack = new ItemStack(); } } } } } } } Basicly what I do here is right click a sign wich says "planks" on the first row and "acacia" on the second. This totally works (thanks for that) but how do I get an item out of this now?
-
Hey guys, Is there a simple way to give a player an item variant (sort of wood, color of wool, etc...) without the player knowing it's specific ID. In other words: Is there like a method that would accept the standard name (for example Birch Wood Plank) and output that item (or it's ID so I can work with that)?
-
Works like a charm. Thanks alot
-
Oh great thanks, this succesfully works on normal potions. But how would I get a splash or lingering potion? Cause PotionTypes doesn't specify that.
-
Okay, now this PotionUtils.appendEffects(new ItemStack(Items.POTIONITEM), Collections.singleton(potion)); gives an error, wrong argument for method. So how do I make an ItemStack from the PotionType? PotionType potion = PotionType.getPotionTypeForName(potionString); ItemStack itemstack = new ItemStack(potion,1); doesn't work either
-
That did indeed work. Thanks. But what I get now is a Waterbottle with an effect. What input would I need to send in order to get an actual vanilla potion?
-
If I would start with a String input (the name of a vanilla potion), how would I end up with an ItemStack of that potion? The input ofcourse is something the player gives and thus can be any potion that exists. Anyone has any idea? I tried this Potion potion = Potion.getPotionFromResourceLocation(potionString); but i can't make an ItemStack with that.
-
Execution failed for ':decompileMc' - GC overhead limit exceeded
Zeurkous replied to Jay Avery's topic in Modder Support
Hmm for me I had to increase the RAM for Java. Don't remember how exactly u do that, but google helped me out for that one. http://www.wikihow.com/Increase-Java-Memory-in-Windows-7 -
Execution failed for ':decompileMc' - GC overhead limit exceeded
Zeurkous replied to Jay Avery's topic in Modder Support
When I tried installing forge a week ago I also kept getting that error. I tried 10 solution but when I realised I placed that file in the wrong folder I just started clean from the tutorial from the forge site itself (the one you followed) and it worked first time. So I suggest starting from scratch with the file placed correctly. If that doesn't work then I don't know what the problem is and someone more experienced than me should take a look. -
Execution failed for ':decompileMc' - GC overhead limit exceeded
Zeurkous replied to Jay Avery's topic in Modder Support
I made the same mistake as you did. Place that file in your home folder/.gradle So if your name would be John, that would probably be C:\Users\John -
[1.9.4]Adding custom attribute to EntityPlayer
Zeurkous replied to Zeurkous's topic in Modder Support
Okay, thanks a lot guys. If I happen to have a question about the packet stuff I'll open a new topic I guess. -
[1.9.4]Adding custom attribute to EntityPlayer
Zeurkous replied to Zeurkous's topic in Modder Support
Alright I'll look into that And what would be the Singleplayer equivalent of PlayerLoggedIn? -
[1.9.4]Adding custom attribute to EntityPlayer
Zeurkous replied to Zeurkous's topic in Modder Support
Ofcourse Thanks. Almost getting it to work as it should. I now have 2 more problems. [*]Whenever I rejoin my world the client resets the value to it's base while the server keeps the correct value. How do I fix that? (Packets and Pakcet handling?) [*]I made a RightClickBlock event but every now and again it decides to fire twice on the same right click (both for client and server). Any ideas on that? -
[1.9.4]Adding custom attribute to EntityPlayer
Zeurkous replied to Zeurkous's topic in Modder Support
Okay I got it to work somewhat. Now if I wanted to give the player a starting value (of money in this case) what event would be best suited for that? Singleplayer and Multiplayer speaking (if that would be different) -
[1.9.4]Adding custom attribute to EntityPlayer
Zeurkous replied to Zeurkous's topic in Modder Support
Thought so, so this is what I have found. But it gives an error when the world loads. public class CapabilityMoney { @CapabilityInject(IMoney.class) public static final Capability<IMoney> MONEY_CAPABILITY = null; public static final EnumFacing DEFAULT_FACING = null; public static final ResourceLocation ID = new ResourceLocation(Main.MODID, "Money"); public static void register() { CapabilityManager.INSTANCE.register(IMoney.class, new Capability.IStorage<IMoney>() { @Override public NBTBase writeNBT(Capability<IMoney> capability, IMoney instance, EnumFacing side) { return new NBTTagInt(instance.getMoney()); } @Override public void readNBT(Capability<IMoney> capability, IMoney instance, EnumFacing side, NBTBase nbt) { instance.setMoney(((NBTTagInt) nbt).getInt()); } },() -> new Money(null)); MinecraftForge.EVENT_BUS.register(new EventHandler()); } public static IMoney getMoney(EntityPlayer player) { return CapabilityUtils.getCapability(player, MONEY_CAPABILITY, DEFAULT_FACING); } public static ICapabilityProvider createProvider(IMoney money) { return new SimpleCapabilityProvider<>(MONEY_CAPABILITY, DEFAULT_FACING, money); } public static class EventHandler { @SubscribeEvent public void attachCapabilities(AttachCapabilitiesEvent.Entity event) { if (event.getEntity() instanceof EntityPlayer) { final Money money = new Money((EntityPlayer) event.getEntity()); event.addCapability(ID, createProvider(money)); } } @SubscribeEvent public void playerClone(PlayerEvent.Clone event) { final IMoney oldMoney = getMoney(event.getOriginal()); final IMoney newMoney = getMoney(event.getEntityPlayer()); if (newMoney != null && oldMoney != null) { newMoney.setMoney(oldMoney.getMoney()); } } } } public interface IMoney { int getMoney(); void setMoney(int moneyToSet); void addMoney(int moneyToAdd); } public class Money implements IMoney{ protected static final UUID MODIFIER_ID = UUID.fromString("d5d0d878-b3c2-469b-ba89-ac01c0635a9c"); protected static final String MODIFIER_NAME = "Money"; protected static final int MIN_AMOUNT = 0; private final EntityPlayer player; private int money; public Money(EntityPlayer player) { this.player = player; } public static final IAttribute MONEY_ATT = (new RangedAttribute((IAttribute)null, "money", 1000,0,1000000000)).setDescription("Money").setShouldWatch(true); private final IAttributeInstance dummyMoneyAttribute = new AttributeMap().registerAttribute(MONEY_ATT); @Override public final int getMoney() { return money; } /** * Set the bonus max health. * * @param bonusMaxHealth The bonus max health */ @Override public final void setMoney(int money) { this.money = money; onMoneyChanged(); } @Override public final void addMoney(int moneyToAdd) { setMoney(getMoney() + moneyToAdd); } protected AttributeModifier createModifier() { return new AttributeModifier(MODIFIER_ID, MODIFIER_NAME, getMoney(), Constants.ATTRIBUTE_MODIFIER_OPERATION_ADD); } protected void onMoneyChanged() { if (player == null) return; final IAttributeInstance playerMoneyAttribute; playerMoneyAttribute = player.getEntityAttribute(MONEY_ATT); dummyMoneyAttribute.getModifiers().stream().forEach(dummyMoneyAttribute::removeModifier); dummyMoneyAttribute.setBaseValue(playerMoneyAttribute.getBaseValue()); playerMoneyAttribute.getModifiers().stream().filter(modifier -> !modifier.getID().equals(MODIFIER_ID)).forEach(dummyMoneyAttribute::applyModifier); AttributeModifier modifier = createModifier(); dummyMoneyAttribute.applyModifier(modifier); final AttributeModifier oldModifier = playerMoneyAttribute.getModifier(MODIFIER_ID); if (oldModifier != null) { playerMoneyAttribute.removeModifier(oldModifier); } else { } playerMoneyAttribute.applyModifier(modifier); } } This I got from a tutorial from Choonster. I understand most of it (not the dummy part) but it give as error at playerMoneyAttribute.getBaseValue(); (Class Money.java) player.getEntityAttribute(MONEY_ATT) return null appaerently so .getBaseValue() gives null pointer. Not sure if I'm doing something wrong or if I'm not doing something I should. -
Hey guys, I'm really new to modding so please go easy on me I'm currently making a mod purely for educational purposes. So my question: I'd like to add a custom attribute (which i already made) to the player. How would I go about this? Here is the attribute public static final IAttribute MONEY_ATT = (new RangedAttribute((IAttribute)null, "money", 1000,0,1000000000)).setDescription("Money").setShouldWatch(true); It's really something stupid but i'm trying to learn. I've found how to add attributes to new entities and modify existing onces but this i can't find. I hope someone can help me out. Greetings; Zeurkous