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

Sandblock - Property Question.


Recommended Posts

I have walked through the Sandblock, which is part of the Falling block..

 

though there is one question I can't seem to figure out what it does.. or why exactly it's important.

dustColorIn --  IT passes an int into ' getDustColor '... but I can't seem to grasp as to what numbers are imporant or what they mean.

Link to post
Share on other sites
16 hours ago, ChampionAsh5357 said:

It's just the color of the particle to render for the falling block. If you want, you can translate the colors into hex and put them into a color editor to view what colors they are.

Just a quick follow up on that..

 

if hex is 16 base 0-f,  how exactly is a - f represented?    or is the range 0-9 where what    

Do is use the 0xffffff  for say.. white.   or 999999 ??  
--  honestly I am unsure where the hex input came from in my head into an int slot.

Link to post
Share on other sites

The number you see is in decimal. If you convert it to hexidecimal you will get a familiar 0xAARRGGBB

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites
34 minutes ago, Draco18s said:

The number you see is in decimal. If you convert it to hexidecimal you will get a familiar 0xAARRGGBB

Ummm  So it accepts an 'alpha' value?   X.x I swear some things are obtuse to be obtuse.
--(also it seems to have accepted 0xffffff just fine.. though it took a while to suspend meh block as it's got all the same properties of sand.)
-- I still would have had questions, though the first one would have made 100x more sense.

I had not seen the value, and I had only backtraced from 'SandBlock' to 'FallingBlock' to 'Block',  for the proper overrides & inclusions for tooltips, and was unsure of the 'valid' input range as I know that some like light level can accept greater than 15, but creates a weird visual effect  past 15.
--- also,  thanks for the prodding  I found an something I think might be an interesting way to enable/disable falling on blocks of sand.  it was always a real shame that sand & gravel have such nice particles & no real way to suspend them.
 

I apparently did not find the 'blocks' java class for minecraft til just now.  
--  followed the extends back... but I apparently didn't think to follow them forward again to see where it was used to view the official uses as an example [Honestly I didn't think it would be in there]

--------------------------------------------------------------------

 also, so I'm not unclear this is what my 'sand' constructor looks like.  {Use to look like}

package com.dephoegon.reclaim.aid.block;

import com.dephoegon.reclaim.aid.util.kb;
import net.minecraft.block.SandBlock;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.IBlockReader;

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

public class sand extends SandBlock {
    private static String tip0;
    private static String tip1;
    private static String tip2;
    public sand(int dustColorIn, Properties properties, String normtoolTip, String shiftToolTip, String ctrlToolTip) {
        super(dustColorIn, properties);
        if (normtoolTip != "") { tip0 = normtoolTip; } else { tip0 = null; }
        if (shiftToolTip != "") { tip1 = shiftToolTip; } else { tip1 = null; }
        if (ctrlToolTip != "") { tip2 = ctrlToolTip; } else { tip2 = null; }
    }

    @Override
    public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn)
    {
    -- snipped -- LongStory Short, logic to display tooltip & avoidance of null values and problems for blocks that don't get assigned a tooltip  
    }
}

& this is what 'for now my sand block(s) look like [also the 2,2 was just a holder till I looked it up for sure..  though I found where they are.. and I can do that easier now]

package com.dephoegon.reclaim.block.sand;

import com.dephoegon.reclaim.aid.block.sand;
import com.dephoegon.reclaim.aid.util.registration;
import com.dephoegon.reclaim.reclaim;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.RegistryObject;

import java.util.function.Supplier;

public class altcolor {
    public static final RegistryObject<Block> WHITE_SAND = register("white_sand",
            () -> new sand(0xffffff, AbstractBlock.Properties.create(Material.SAND)
                    .hardnessAndResistance(2,2)
                    .harvestLevel(1).harvestTool(ToolType.SHOVEL),"","",""));

    public static void register() { }

    public static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block) {
        RegistryObject<T> exit = registration.BLOCKS.register(name, block);
        registration.ITEMS.register(name, () -> new BlockItem(exit.get(),
                new Item.Properties().group(reclaim.RECLAIM_COMPRESSION)));
        return exit;
    }
}

 

Link to post
Share on other sites

Whether or not it actually uses the alpha value depends on various other factors.

(And of course it accepts 0xffffff: that's a valid integer literal)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites
15 minutes ago, Draco18s said:

Whether or not it actually uses the alpha value depends on various other factors.

(And of course it accepts 0xffffff: that's a valid integer literal)

Hey....  xD. I'm not use to hex values being used directly. Maybe it maybe me..... but i think dec when i see int....  (my failure i know)

 

Though...  one last question.   How do you get a vanilla block yo use a custom class.

To clarify i got my sand class setup to allow/disallow 'falling', by checking for a certain block above it (and will check through a tower of the same block)..

I would like to include the vanilla minecraft sands, without replacing them.

I'm not exactly sure how to start looking, might need to just do another block... but I'd rather use the vanilla block if possible. 

Link to post
Share on other sites

Look at the Blocks class.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites
10 hours ago, Draco18s said:

Look at the Blocks class.

I'm going to be upfront..  I didn't understand what you wanted me to see in it.  (Unless you mean how MC did their registries)     I think I got a grasp on 'what' it kinda expects ... I'm just going to post a relevant question to what I'm trying to understand now.

Link to post
Share on other sites

Ignore the operational code and think about what the class exposes to other classes.

What fields and properties does it have?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites
28 minutes ago, Draco18s said:

Ignore the operational code and think about what the class exposes to other classes.

What fields and properties does it have?

From what I can .. gather, and I'm sure this is my confusion going on..        It has public Objects that are effectively the block registry calls.

Wait?  Would it be possible to actually override a public object, and have it use it? ---   

 

I'm not sure I understand,   though the only bit I can honestly gather from that is a string name key, & the block object calling a new instance of a block (sand, log, etc) with properties defined in those block classes, which are often calling abstractblocks for properties, and extending special classes (like fallingblock) which tend to fall onto blocks, then abstract blocks themselves.

 

perhaps I'm missing the forest for the trees (or missing the trees for the forest), but  I'm not getting how you meant that.

Link to post
Share on other sites
5 hours ago, DePhoegon said:

 though the only bit I can honestly gather from that is a string name key, & the block object calling a new instance of a block (sand, log, etc) with properties defined in those block classes, which are often calling abstractblocks for properties, and extending special classes (like fallingblock) which tend to fall onto blocks, then abstract blocks themselves.

Ignore that stuff. It's not relevant.

5 hours ago, DePhoegon said:

public Objects

This. These are accessible from your code.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites
19 minutes ago, Draco18s said:

..

This. These are accessible from your code.

Ok, I 'think' i get the angle. 
-- I also, have gotten some .. idea of how other special classes are .. structured from that same page. 

I feel as if there is an 'answer' in front of my face, and I'm not exactly connecting the dots.

I am left wondering,   'Accessible from' my code, which implies a possibility of changing/overriding it and having the native code take it.
-- or it just means I could use that object in my own registry, but I am confused as to what is & isn't useful .

I can register those objects, but I am left with the requirements (assuming, basic override/injecting a subclass w/ behavior overrides)
- That it still work & registered to the same namespace for the item & modid (minecraft & sand, in this case)for compatibility of all other aspects & interactions calling it else where.
- That it clearly behaves with the additional override (this case, literally sticking to it self if a certain slab is sitting above it & it's all the same block to it)

I feel actually kind of stupid, I can hold the object in a manner of speaking.. but I don't know what it'll take get it in there. [I have a 'solution' working, but I genuinely don't understand why it works exactly]

Thank you for your time.  I just have the feeling, I'm not looking at the pieces correctly and my way of thinking is ignoring an aspect that could lead to a far better understanding & solution. >.>   i should let this roll around in my head like the sphere of an object it is,  perhaps I am missing something extensively obvious .. but it'll show it self in time. 

Link to post
Share on other sites
//your code
Block b = Blocks.SAND;

:|

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites
31 minutes ago, Draco18s said:

//your code
Block b = Blocks.SAND;

:|

Ok...  i got to admit, I am both thoroughly  unsure and confused.   I think we need a common understanding of where  I am on my code & thinking..   I'll just share the github link of it.
-- in aid/util/registration.java   is where I am atm, and i currently have the overrides in ./block/sand/altcolor.java  
-- Mod Code

I don't think I achieved the same spot, but perhaps this can help show 'how' I'm thinking about things, as I may not be grasping how you are phrasing things, or as easily I didn't communicate well enough and we don't aren't understanding the same intent, though I am grateful for your attempts at helping to say the least.

Link to post
Share on other sites

Oh dear god.

All of these do fucking nothing. Every single one of those methods is empty.

Also, class names start with an UpperCaseLetter.

Why the fuck is this Object?

You really like Pokemon Exceptions. You don't even need try-catch. That's what instanceof is for.

This can't even throw an exception.

And apparently you have something against != as well.

You aren't even using this value.

Do not do pointless logging.

fall = falls is too hard?

This entire method is a fucking nightmare. Also str.isEmpty().

 

And I still don't know where you are trying to check the block above, per your original post.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites
7 minutes ago, Draco18s said:

All of these do fucking nothing. Every single one of those methods is empty.

They force the class to load, so the registry objects get registered. Which is a TERRIBLE way to do this. Just put the deferred register and its objects in the same class.

 

 

Link to post
Share on other sites
2 hours ago, diesieben07 said:

They force the class to load, so the registry objects get registered. Which is a TERRIBLE way to do this. Just put the deferred register and its objects in the same class.

Ok that's fair.
But it's still terrible.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites
Posted (edited)
3 hours ago, Draco18s said:

Oh dear god.

All of these do fucking nothing. Every single one of those methods is empty.

Also, class names start with an UpperCaseLetter.

Why the fuck is this Object?

You really like Pokemon Exceptions. You don't even need try-catch. That's what instanceof is for.

This can't even throw an exception.

And apparently you have something against != as well.

You aren't even using this value.

Do not do pointless logging.

fall = falls is too hard?

This entire method is a fucking nightmare. Also str.isEmpty().

 

And I still don't know where you are trying to check the block above, per your original post.

In order, X}  

1.  (Force class to load, as was explained)  and was how it was shown.. I am up for 'changing it up' & optimizing it later,     That's  just the method that was shown.  I want to optimize it later for sure.

2.o_hand  ->   is offhand   I got sick to death of doing typos, and used it & m_hand for main hand ...   (offhand is the shield slot typically)

2. .... actually [ target = (LivingEntity)event.getTarget(); ]  inside of  (AttackEntityEvent event) is 100% capable of causing an error.
-- Try setting it up & smacking with any melee attack (fist or weapon) the following
a.  Any Minecart
b. Any End Crystal
c. Any Item Frame.
d. Any Boat   
----  it literally causes the game to close with an exception.   All those things can both 'trigger the attackEntity event'  and be inside the target of the player, which will cause an exception when cast into a (Living Entity), which was used to apply the potion effects...
~~ Strangely enough,  a armor stand  not only is uneffected by it, but can accept potions applied to it as well.

3.  It does do something,  It fails & does nothing, which means 'target' is null still, and no potion effects get applied to the target that was hit.
--- which means, it prevents the game from being shut down from an unintended casting of a target into a living entity object (which is needed to apply potion effects on)

4.  That's just nitpicking really,  That's an old logic habit....    Some reason it slipped my mind,  either way,     (!(thing == thing)) same effect of (thing != thing)  
---likely I honestly fell back into an old habit when inverse of true statement was my thought on that.

5. I know...  It's not complete (i've not  finished the blocks, as I'm working towards combat centric things, and I'm debating what I want to do with it)
--- also,  to note, I remember why I put try { atker = (LivingEntity)livi.getAttackingEntity(); } catch (Exception e) { }  (for future use)      things like minecarts & end crystals can harm the player & other entities, and that event fires when an entity get hurt.... and given I just got off of just randomly finding out that casting the target of my hit into a (living entity) object can cause fatal exceptions, it's there to 'do NOTHING' if that happens, and an prevent fatal exceptions from going off because of a weird entity causing damage that isn't a livingentity for some reason.
~~~  Yes I plan to use it later..    that was for an armor thing.

6. meh...   Again   alot of the primary page is tutorial code....   I left what was shown,  and I'm learning what does what.. .and pruning what doesn't work.   
-- yes, it annoys me as well but that's not on the short list atm.

7. as for 'fall = falls'  . I don't like doing that, as i prefer the geniune fallback if some unknown reason happens  a valid variable gets assign (right or wrong) and prevents weird unknown errors.

8.  The method is 100% straight forward    It's just a nested if loop that of course tests each string once (effectively) and doesn't attempt to assign an empty tooltip.
_NormToolTip Is on it w/ no shift or cntl held down (either one)
_When shift or cntrl is held down,  it shows the correct one.
_When Shift & Cntrl are held down.. it shows Cntrl over Shift.
---- to be fair I actually didn't think to check for a method that checks if  a string is empty.
~~~  It uses Exclusionary logic, but if you can think of a faster way of doing 
-normal tooltip (no keys held)
-Shift Tooltip (either shift held)
-Cntl ToolTip (either Cntrl held)
-Cntl tooltip over  Shift tooltip (when a Cntrl & Shift is held, either side)
 I'm all ears if you think you can do that faster and prevent it from using a null value.

Edited by DePhoegon
clarifications & reasons for 'seemingly useless' things.
Link to post
Share on other sites
7 hours ago, DePhoegon said:

----  it literally causes the game to close with an exception.   All those things can both 'trigger the attackEntity event'  and be inside the target of the player, which will cause an exception when cast into a (Living Entity), which was used to apply the potion effects...
~~ Strangely enough,  a armor stand  not only is uneffected by it, but can accept potions applied to it as well.

And this is why you don't blindly cast something but use instanceof.

Link to post
Share on other sites
2 hours ago, diesieben07 said:

And this is why you don't blindly cast something but use instanceof.

very true...    something to consider. 

 

Now the question,  which one is is better, speed wise.   (i know it's far better not produce errors or exceptions if you can help it, and this is more a  thought experiment)
 { target = (LivingEntity)event.getTarget(); } catch (Exception e) { } 
if (event.getTarget() instanceof (LivingEntity)) { target = (LivingEntity)event.getTarget(); }
---  don't roast me on the instance of syntax,    I've not actually written it out yet

Link to post
Share on other sites

Premature optimization is the root of all evil. Do not write code in a particular way because it is "faster".

The way to do this is to use instanceof. Blindly casting and catching any and all exceptions is just terrible.

Link to post
Share on other sites
14 minutes ago, diesieben07 said:

Premature optimization is the root of all evil. Do not write code in a particular way because it is "faster".

The way to do this is to use instanceof. Blindly casting and catching any and all exceptions is just terrible.

Well I figured, about the blind casting, just comes across as a potential problem, even if caught as it self still doesn't exactly solve the issue persay is just the logic of relying on the fail safe with known faults, rather then attempting to not use the faults.
-- I had honestly not thought of instanceof (despite using it in the same file elsewhere, no excuse just likely exhausted when I did it)

I was going to use instanceof, and hopefully test it in a variety pack near the end (checking to see if false players that smack things would trigger it, and how to avoid such things)
--  this for later I suppose.

proper methods trump shortcuts..  

 

gotta work to see if i can figure out how to put stairs in, or what i'm not getting there. (got walls/fences/glass panes next... then of course all the supporting json for models, and teh textures.. but  that's not done yet x})

Link to post
Share on other sites
14 hours ago, DePhoegon said:

2.o_hand  ->   is offhand   I got sick to death of doing typos, and used it & m_hand for main hand ...   (offhand is the shield slot typically)

No, why is it's Type Object and not Item?

14 hours ago, DePhoegon said:

2. .... actually [ target = (LivingEntity)event.getTarget(); ]  inside of  (AttackEntityEvent event) is 100% capable of causing an error.

This is why you use instanceof.

14 hours ago, DePhoegon said:

3.  It does do something,  It fails & does nothing, which means 'target' is null still, and no potion effects get applied to the target that was hit.
--- which means, it prevents the game from being shut down from an unintended casting of a target into a living entity object (which is needed to apply potion effects on)

Sorry, a couple of the links got messed up. And I noticed the forum screwing up my post writing this one (I'll be at the end of a line, make a typo, hit backspace, and the cursor jumps to the middle of the line and deletes a character. I meant this section.

You've fixed it, but now you have two checks for null where you could just combine the two blocks and do it once. No sense checking to see if there's a valid object to assign with and then separately checking to see if you assigned anything to it...

14 hours ago, DePhoegon said:

7. as for 'fall = falls'  . I don't like doing that, as i prefer the geniune fallback if some unknown reason happens  a valid variable gets assign (right or wrong) and prevents weird unknown errors.

The two variables are the same type. It's literally pointless. It can never fail in an unexpected way, and if it does, let the program crash, it's not your problem.

14 hours ago, DePhoegon said:

8.  The method is 100% straight forward    It's just a nested if loop that of course tests each string once (effectively) and doesn't attempt to assign an empty tooltip.

And I made it simpler and easier to read.

public void addInformation(ItemStack stack, IBlockReader worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
	if(!kb.HShift() && !kb.HCtrl() && !tip0.isEmpty()) tooltip.add(new StringTextComponent(tip0)); //if neither pressed, show tip0 (if not empty)
	if(kb.HCtrl() && !tip2.isEmpty()) tooltip.add(new StringTextComponent(tip2)); //if ctrl, show tip2 (if not empty), do first
	if(kb.HShift() && !tip1.isEmpty()) tooltip.add(new StringTextComponent(tip1)); //if shift, show tip1 (if not empty)
}

 

3 hours ago, DePhoegon said:

Now the question,  which one is is better, speed wise.

instanceof. Try-catch is monumentally slow. I've actually tested this. Inadvertently, but I did (that's what happens when you're doing reflection inside bytecode manipulation and discover that the game is running at 20 SPT instead of 20 TPS and fix it by removing the try-catch and just letting your injected method throw an error you know will never actually be thrown and bypass the compiler check for unhandled exceptions).

But if course, if you had to ask that question after implementing one over the other because, in your own words, "it was faster" you obviously didn't even bother doing a test to find out if it was actually true.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites
1 hour ago, Draco18s said:

instanceof. Try-catch is monumentally slow. I've actually tested this. Inadvertently, but I did (that's what happens when you're doing reflection inside bytecode manipulation and discover that the game is running at 20 SPT instead of 20 TPS and fix it by removing the try-catch and just letting your injected method throw an error you know will never actually be thrown and bypass the compiler check for unhandled exceptions).

But if course, if you had to ask that question after implementing one over the other because, in your own words, "it was faster" you obviously didn't even bother doing a test to find out if it was actually true.

Umm  I didn't do it 'because it was faster'  I asked it as an after thought, a curiosity ...  nothing more.    would you kindly not assume why I used the method.
---  psst...  I used try Catch when I was dead tired & to give feedback..  it wasn't meant as the end goal, though I should have noted to find the proper method later.

 

1 hour ago, Draco18s said:

 


public void addInformation(ItemStack stack, IBlockReader worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
	if(!kb.HShift() && !kb.HCtrl() && !tip0.isEmpty()) tooltip.add(new StringTextComponent(tip0)); //if neither pressed, show tip0 (if not empty)
	if(kb.HCtrl() && !tip2.isEmpty()) tooltip.add(new StringTextComponent(tip2)); //if ctrl, show tip2 (if not empty), do first
	if(kb.HShift() && !tip1.isEmpty()) tooltip.add(new StringTextComponent(tip1)); //if shift, show tip1 (if not empty)
}

 

Easier to read, maybe... but it's checking for KB inputs each game tick for that item... which isn't something I believe is helpful.  
--  This is likely a point of ...  personal thought, I'd rather not have 4 kb checks a tick per item hovered over.  (2 each for Shift & Cntrl) 
~~ I prefer to minimize keyboard checking, though I will keep that in mind.

also,  I'm more the fan of null checks, but ... that's a preference thing honestly.

 

1 hour ago, Draco18s said:

You've fixed it, but now you have two checks for null where you could just combine the two blocks and do it once. No sense checking to see if there's a valid object to assign with and then separately checking to see if you assigned anything to it...

The two variables are the same type. It's literally pointless. It can never fail in an unexpected way, and if it does, let the program crash, it's not your problem.

Because ..  This mod is made with intents of being with other mods, and I will fully admit I do not trust other mods and 'fake players',  I don't know what will happen & haven't gotten my mod to a stage where I can viably test it in a variety pack with matters I'm worried about.
-- what if a fake player is null, & a player entity, so it doesn't fail or cause MC issues, but will cause issues if it's used improperly.
~~~ I understand with vanilla, regular ol minecraft    It's overkill & one check would be enough, or exclusion from a fake player I made (if I made one, which I am not the biggest fans of myself)

"It would never fail in an unexpected way"  ....   Minecraft literally can crash because an event built for it will trigger  on entities that can't be cast into the event for what it was intended for.  A tiny bit of caution wouldn't go amis.
-- also, I left room to a dynamic change to the logic.  I know it's not final, and it's verbose at worst.

1 hour ago, Draco18s said:

No, why is it's Type Object and not Item?

eh, first thing I thought of if I where to be honest...  use null object that can become the item compare to a specific thing.
_-  as well, object work straight out of the gate so I didn't bother to look for better.

Changed it, as I'd rather keep logic sane enough X]
--  still learning 'java' and dealing with mc moding,  I honestly am relying on feed back from the IDE ALOT, ontop of research of things.

-------------------------------

Oh, ya, going to x.x new post about ....  stairs  I need to figure out the 'other method' for them  I can't seem to get it right.
-atm I am using the Deprecated method.... but I barely understand it. [it's in the code, I'm working on altcolor sand textures.... then I'm going to give them the models in game & then the stairs.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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