Package: dfpyre
pyreA package for external creation of code templates for the DiamondFire Minecraft server (mcdiamondfire.com).PyPi Link:https://pypi.org/project/dfpyre/FeaturesAll code block typesAll code item typesDirect sending to DF via recodeAutomatic type conversion (int to num, str to text)Name checking ("did you mean ___?" for close matches)Default tag valuesDocumentationBasicsSetting up a programEvents and ActionsBuildingVar ItemsTextNumberVariableLocationItemSoundParticlePotionGame ValueVectorConditionals and LoopsConditionals and BracketsLoopsFunctions and ProceduresCreating Functions and ProceduresCalling Functions and ProceduresExtrasMethod ListSetupTo start creating in pyre, you have to create a DFTemplate object like so:fromdfpyreimport*t=DFTemplate()Basically everything stems from this template object.This is the basic layout of a file:fromdfpyreimport*t=DFTemplate()# [Event, Function, or Process]# [Your code here]t.build()The commented lines represent where you will insert calls to methods in the template object.Here's a complete program that prints a message to every player when a player joins:fromdfpyreimport*t=DFTemplate()t.playerEvent('Join')t.playerAction('SendMessage','%default has joined!',target=Target.ALL_PLAYERS)t.buildAndSend()Events/ActionsYou can find a list of events and actionshereAs shown insetup, every code line must start with an event, function, or process. After that, you're free to put anything you want.The following program sends a message to all players and gives a player 10 apples upon joining:fromdfpyreimport*t=DFTemplate()t.playerEvent('Join')t.playerAction('SendMessage','%default has joined!',target=Target.ALL_PLAYERS)t.playerAction('GiveItems',item('apple',10))BuildingYou basically have 2 different options for building your code line.
You can either:Save the compressed template code to a variable and send it to minecraft laterBuild and send directly to your minecraft client (recommended)If you choose the first option, the code would look something like this:fromdfpyreimport*t=DFTemplate()t.playerEvent('Join')t.playerAction('SendMessage','%default has joined!',target=Target.ALL_PLAYERS)templateCode=t.build()sendToDf(code,name='myJoinTemplate')# Send to minecraft client via recode item apiIf you choose the second option, you can do this:fromdfpyreimport*t=DFTemplate()t.playerEvent('Join')t.playerAction('SendMessage','%default has joined!',target=Target.ALL_PLAYERS)t.buildAndSend()# builds and sends automatically to minecraftVariable ItemsTextRepresents a diamondfire text item:text('hello%default.')If a regular string is passed to a method as a chest parameter, it will automatically be converted to a text object:# These do the same thing:t.playerAction('SendMessage',text('%default joined.'))t.playerAction('SendMessage','%default joined.')NumberRepresents a diamondfire number item:num(5)num(3.14)If a regular integer or float is passed to a method as a chest parameter, it will automatically be converted to a num object:# These do the same thing:t.setVariable('=',var('number'),num(10))t.setVariable('=',var('number'),10)VariableRepresents a diamondfire variable item:var('num')var('text1')You can set variable values by using thesetVariablemethod:t.setVariable('=',var('num'),12)# sets 'num' to 12t.setVariable('x',var('doubled'),var('num'),2)# sets 'doubled' to 24You can set the scope of the variable by using thescopekeyword:t.setVariable('=',var(num1,scope='game'),12)# both 'game' or 'unsaved' can be passed for the scope heret.setVariable('=',var(num1,scope='saved'),12)t.setVariable('=',var(num1,scope='local'),12)LocationRepresents a diamondfire location item:# (var= is not required if numbers are in order, but is more readable)loc(x=25.5,y=50,z=25.5,pitch=0,yaw=-90)Example:# teleport player on joinfromdfpyreimport*t=DFTemplate()t.playerEvent('Join')t.playerAction('Teleport',loc(10,50,10))ItemRepresents a minecraft item:item('stick',count=5)item('stone',64)Extra nbt (enchants, lore, etc.) is not supported right now.SoundRepresents a diamondfire sound item:sound('Wood Break',pitch=1.5,vol=2.0)Example:# plays 'Grass Place' sound on joinfromdfpyreimport*t=DFTemplate()t.playerEvent('Join')t.playerAction('PlaySound',sound('Grass Place'))ParticleRepresents a diamondfire particle item:particle(name='Cloud',amount=10,horizontal=1.0,vertical=0.5,x=1.0,y=0.0,z=0.0,motionVariation=100)Example:# plays a white cloud particle effect at 5, 50, 5fromdfpyreimport*t=DFTemplate()t.playerEvent('Join')t.playerAction('Particle',particle('Cloud'),loc(5,50,5))Currently, the particle object does not support colors.PotionRepresents a diamondfire potion item:# gives speed 1 for 1 minutepotion('Speed',dur=1200,amp=0)Example:# gives the player infinite saturation 255fromdfpyreimport*t=DFTemplate()t.playerEvent('Join')t.playerAction('GivePotion',potion('Saturation',amp=254))Game ValueRepresents a diamondfire game value item:gamevalue('Player Count')gamevalue('Location'target='Selection')Example:# function that prints player count and cpufromdfpyreimport*t=DFTemplate()t.function('printData')t.playerAction('SendMessage',gamevalue('Player Count'),gamevalue('CPU Usage'))VectorRepresents a diamondfire vector item:vector(x=1.1,y=0.0,z=0.5)Example:# sets the player's x velocity to 1.0 on joinfromdfpyreimport*t=DFTemplate()t.playerEvent('Join')t.playerAction('SetVelocity',vector(x=1.0,y=0.0,z=0.0))ParameterRepresents a diamondfire parameter item:parameter('text',ParameterType.STRING)Example:# builds a function that says "Hello, [name]" where `name` is the inputted parameter.fromdfpyreimport*t=DFTemplate()nameParameter=parameter('name',ParameterType.TEXT)t.function('SayHi',nameParameter)t.playerAction('SendMessage','Hello, ',var('name','line'))Conditionals/BracketsA list of conditionals and loops can be foundhere.A specific syntax must be followed when creating conditionals and loops. Each conditional statement must be followed by abracket()method, which will contain code. Here's an example:# prints 'clicked' when a player right clicks with a stick in their handfromdfpyreimport*t=DFTemplate()t.playerEvent('RightClick')t.ifPlayer('IsHolding',item('stick'))t.bracket(t.playerAction('SendMessage','clicked'))To create anelsestatement, use theelse_method:# says the player is 'on the ground' when grounded and 'in the air' otherwise.fromdfpyreimport*t=DFTemplate()t.function('grounded')t.ifPlayer('IsGrounded')t.bracket(t.playerAction('ActionBar','on the ground'))t.else_()t.bracket(t.playerAction('ActionBar','in the air'))t.build()LoopsAs for loops, the bracket syntax is the same and will automatically change to "repeat-type" brackets:# prints numbers 1-5fromdfpyreimport*t=DFTemplate()t.playerEvent('Join')t.repeat('Multiple',var('i'),5)t.bracket(t.playerAction('SendMessage',var('i')))Creating Functions/ProcessesTo create a function or process, just start the template with afunctionorprocessmethod:# function that gives a player 64 golden applesfromdfpyreimport*t=DFTemplate()t.function('doStuff')t.playerAction('GiveItems',item('golden_apple',64))Calling Functions/ProcessesCalling Functions and processes is also simple:fromdfpyreimport*t=DFTemplate()t.playerEvent('Join')t.callFunction('doStuff')Method ListEvents / Function / ProcessplayerEvententityEventfunctionprocesscallFunctionstartProcessActionsplayerActiongameActionentityActionConditionals / LoopsifPlayerifVariableifGameifEntityelse_ (don't forget underscore)repeatbracketOthercontrolselectObjectsetVariable